Linux下bash脚本借用tr命令批量修改文件名 (Change file name by command ‘tr’ using bash script under Linux)

bash脚本调用tr命令修改文件名,tr命令参数由用户指定。The bash script will call command ‘tr’ to change file names. parameters transfered to ‘tr’ is specified by user.

# Usage: fn-tr -p <tr parameters> -r <file/directory> <file/directory> ...
# -p parameters will transfered to command 'tr'  指定将会传递给tr命令的参数
# -d change directory     对目录执行更改操作
# -f change normal file  对普通文件执行更改操作
# -r recursive  递归搜索子目录

将/docs下文件名中的多个连续空格压缩到一个 remove duplicated white spaces of the filenames under /docs

ftr -p '-s " "' -fr /docs/*

bash脚本下载:bash script download: