The following script will work on directories with less than 100 files of the same type, and will rename all of them to file01, file02, file03, ... and so on.
j=1;You can only use it for certain types of files in a directory, like this:
for i in *; do
if [[ $j -lt 10 ]]; then
mv "${i}" "file0${j}";
fi;
if [[ $j -ge 10 && $j -lt 100 ]]; then
mv "${i}" "file${j}";
fi;
j=$(($j+1));
done
j=1;This will rename all the Ogg files in a directory to audio01.ogg, audio02.ogg, audio03.ogg, and so on. You can test it for whatever files you like, however make a back-up first, since you can accidentally rename files or even directories which you don't want renamed.
for i in *.ogg; do
if [[ $j -lt 10 ]]; then
mv "${i}" "audio0${j}.ogg";
fi;
if [[ $j -ge 10 && $j -lt 100 ]]; then
mv "${i}" "audio${j}.ogg";
fi;
j=$(($j+1));
done
Updated: Jul 07, 2008 (Created: Jul 07, 2008)
4 comments:
mmv does the job in one line
Also, have a look at "seq -w 1 100".
Jaap
man rename
beauty is that it is present on many GNU and/or Linux systems already as part of util-linux package.
krename as a gui does a good job
http://www.krename.net
Post a Comment