Mass-Renaming

This is for all methods described on this page (and wesite :)
Be carefull and test before you let this loose on a production-system.

Q: How can I rename more than one file?

A1: Using 'rename'

I don't use that one. If nobody else gives the details, you will need to check the manpage :)


I used it to change the extension on a bunch of thumbnails that were produced with Bluefish. The extensions were .jpeg and I wanted .jpg. — Anita Lewis 2005/12/04 12:50

rename “from” “to” filename

rename .jpeg .jpg *.jpeg

A2: Using 'mmv'

  mmv '*.*' '#2.#1-renamed'

will rename
“before.after” to “after.before-renamed”
“one.two” to “two.one-renamed”
“up.seven” to “seven.up-renamed

A3: Using 'find' and 'mv'

I don't have an example at hand, but this is very nice for collecting files from different direcories. Be carefull and test before you let this loose on a production-system.

A4: Using 'for' and 'mv'

This is how I rename my photos:

# img_2790.jpg -> 20051015-190548-img_2790.jpg
for PIC in *.jpg ; do \
    mv $PIC $(exif -m -t "Datum und Uhrzeit" $PIC \
    | sed -e "s/://g" -e "s/ /-/")-$PIC ; \
done

# 20051015-190548-img_2790.jpg -> 20051015-190548-2790.jpg
mmv "*-img_*" "#1-#2"

Now their filenames all start with the date and time they were taken. Nice, especially if there are more than one camera in the family which uses the same filenames (and thus beg for pictures with the same name, which will collide when burning them on one CD).

/home/www/LinuxBasics.org/data/pages/tutorials/using/mass-renaming.txt · Last modified: 2008/07/20 21:08 (external edit)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0