Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a bunch of files x1.jpg, x2.jpg, x3.jpg, etc. that need to be named x001.jpg, x002.jpg, x003.jpg, etc. How can I do this?

Edit: I'm running windows but have cygwin installed.

share|improve this question

migrated from stackoverflow.com Aug 6 '10 at 7:26

This question came from our site for professional and enthusiast programmers.

    
Should be on Superuser.com. However, there's lots of freeware/shareware apps that you can download that does this, just google renamer or similar words. –  ho1 Aug 6 '10 at 7:13
    
Thanks, "renamer" was the keyword I was looking for. –  A Person Aug 6 '10 at 7:25
add comment

6 Answers 6

For bulk renaming image files on Windows (as well as resizing, cropping, converting etc.) I often use IrfanView (Freeware)

share|improve this answer
add comment

Which OS? *nix has the rename command line utility which seems to be tailored for exactly this kind of thing.

share|improve this answer
add comment

A more generic approach than rename (which is not available on all *nix), and potentially allowing quite some creativity:

find . -name 'x*' | while read filename; do mv "$filename" $(echo "$filename" | sed -e 's/x/x00/'); done
share|improve this answer
add comment

Cygwin, sweet.

for NEWNUM in $(seq -w 1 100)
do
    OLDNUM=$(echo $NEWNUM | sed -e 's/^0*//')
    echo $OLDNUM $NEWNUM
    # mv x${OLDNUM}.jpg x${NEWNUM}.jpg
done

This should work. Well other than the commented out mv. The -w flag to seq means 'wide', meaning begin pad with zeros when necessary

share|improve this answer
add comment

Multiple or mass renaming can be called batch renaming.

Total Commander is file manager. It has batch rename feature. You can see tutorial there or there.

Irfan View is image browser/editor. It has batch rename too. You can see tutorial there.

I prefer Total Commander. It has Linux clones and they can probably rename files too.

Both these programs are for Windows. Both should work in Linux too by emulation.

share|improve this answer
add comment

In pure bash:

for a in x?.jpg; do mv "$a" "${a/x/x00}"; done
for a in x??.jpg; do mv "$a" "${a/x/x0}"; done
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.