shell修改文件名(二)

时间:2024-11-26 08:32:50

我想修改类似如下一批文件的文件名:
AA01_01.txt
AA01_02.txt
AA01_03.txt
AA01_04.txt

修改成
BB02_01.txt
BB02_02.txt
BB02_03.txt
BB02_04.txt

把文件名的头换下。

==============================================================
for x in `seq 1 4`;do mv AA01_0${x}.txt BB01_0${x}.txt;done

今天才知道rename这个命令...而且看这个可以用perlexpr...

perl:~# rename
Usage: rename [-v] [-n] [-f] perlexpr [filenames]

rename "s/AA/BB/" *.txt