如何将文件从 A0 A1 A2 A3 重命名为 A001 A002 A003 我有这样的重命名代码:
n=$(ls -1 | grep '^A' -c) # find the number for A files
nfiles=$(ls -1 *.obj| grep -v '^A'); # list of all non-A files
for file in $nfiles; # for each of the non-A files
do
n=$(($n+1));
new_file=A$n.obj # new name with next available A file name
mv $file $new_file # rename with new file name
done