Possible Duplicate:
How can I mass rename files from the command line or using a 3rd party tool?

The title says it all.

The problem is that the first nine files of a couple of hundred are named

1.jpg 2.jpg 3.jpg . . . and so on till..

9.jpg

This screws up the order of the files.

Fixing it manually for a couple of thousand folders could take a long time.

i'm willing to do these one folder at a time if not all at once.

Yet I confess to be ignorant of shell code and programming languages.

Instructions for a batch rename utility will be appreciated.

link|improve this question
feedback

closed as exact duplicate by techie007, Moab, Nifle, Sathya Aug 16 '11 at 16:36

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

1 Answer

In a POSIX shell (e.g. bash) you can run

for i in *.jpg ; do
    mv $i `printf '%04d' ${%.jpg}`.jpg
done

This renames all files X.jpg in the current directory to four digits with prefix zero's. Note that it assumes that all files *.jpg have numbers in their base part only.

link|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.