0

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.

1
  • 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, 2010 at 7:13

6 Answers 6

1

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

0

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

0

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
0

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

0

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.

0

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

You must log in to answer this question.