File Renaming using dates and replacing text string

Started by José Oliver-Didier, March 31, 2010, 11:54:18 AM

Previous topic - Next topic

José Oliver-Didier

Is there any way to rename files using exiftool in this form:

IMG_1234.JPG to 100331-1234.JPG

where the "IMG_" is replaced by YYMMDD
blog: http://jmoliver.wordpress.com
flickr:  http://flickr.com/jmoliver

Phil Harvey

Sure, this command will do what you want using the date from DateTimeOriginal:

  exiftool -d %y%m%d-%%-4f.%%e "-filename<datetimeoriginal" -v FILE

where FILE is one or more file or directory names.  The %-4f takes the last 4 characters from the filename (and the extra % is necessary to get this through the date/time parsing).  I also added a -v option for verbose output so you can see what the files get renamed to.  If DateTimeOriginal isn't available, you can use CreateDate, ModifyDate or even FileModifyDate for the source date/time value.

For more information and examples of this feature, see the filename page and the -w option in the exiftool application documentation.

- Phil

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

José Oliver-Didier

blog: http://jmoliver.wordpress.com
flickr:  http://flickr.com/jmoliver