rename 文件重命名
rename 文件重命名
rename 文件重命名
命令格式,文件重命名
1 2 3 4 5 6 7
| rename [-v] [-n] [-f] perlexpr[files]
-v 打印被重命名的文件 -n 只显示被重命名的文件,而不实际重命名 -f 覆盖已经存在的文件
perlexpr 语言格式的正则表达式
|
demo
把 test02.txt 重命名为 test03.txt
1
| rename 's/test02.txt/test03.txt/' test02.txt
|

参数 -v 打印被重命名的文件
1
| rename -v 's/test03.txt/test02.txt/' test03.txt
|

参数 -n 只显示被重命名的文件,而不实际重命名
1
| rename -n 's/test02.txt/test03.txt/' test02.txt [实际没有重命名]
|

参数 -f 覆盖已经存在的文件
1 2
| rename -f 's/test02.txt/test08.txt/' test02.txt rename -f 's/test02.txt/test08.txt/' *.txt [也可以]
|


表达式中 替换用 s ,转化用 y 或者tr
demo : 将文件名改为大写
