LinuxBasics.org

The community that helps people to run Linux

rss
Table of Contents

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).


Copyright (c) by the authors.
Prior to editing, authors agreed to license their contributions by the terms of the GPL.
See our licensing page for details.


Linux® is a registered trademark of Linus Torvalds.


 
  tutorials/using/mass-renaming.txt · Last modified: 2008/07/20 19:08

LinuxBasics.org

Start Linux-Course Tutorials Linux Links Security Blog Forum E-mail List Search Online Chat

Site-Info

Help Get in Touch Making of LBo

Wiki-Control

Powered by

Linux Apache DokuWiki Mailman RUTE ht://Dig