exiftool '-FileName<${DateTimeOriginal}_$Model.%e' -d %Y-%m-%d_%H-%M-%S%%-.c ./DSC_1703.JPG
Yes, the filename has a space in it because the EXIF Model tag has a space in it, but if you're like I am and don't want spaces, it's easy enough to cleanse all the spaces from your filenames (in this case, with underscores) using the following command:
rename 's/ /_/g' *.JPG
Other tags besides Model can be used, too; I happen to want my filenames with Model in them. Of course one can combine these into one shell script called something like
rename-myphotos.sh
. It could look something like this:#! /bin/bash
#
# Rename photos to something like:
# 2011-02-20_03-05-41-1_NIKON D40.JPG where filename is composed
# of date, time, "-" counter (the "." in the "%%-.c" causes the
# counter to start display "0" for non-duplicate filenames), EXIF
# Model tag, and original extension. THIS COMMAND DOES NOT LEAVE THE
# ORIGINAL FILENAME (it is like a "mv" not a "cp")
#
# Can replace ./ at end with directory name, filename, or filename
# pattern with wilcards.
#
# REMOVE "-n" FROM "rename" AND ADJUST FILENAME PATTERN AT END OF
# THAT LINE AS NECESSARY
exiftool '-FileName<${DateTimeOriginal}_$Model.%e' -d %Y-%m-%d_%H-%M-%S%%-.c ./
rename -n 's/ /_/g' ./
Hi, you can avoid the rename command:
ReplyDeleteexiftool '-FileName<${DateTimeOriginal}_${Model;tr/ /_/;s/__+/_/g}.%e' -d %Y-%m-%d_%H-%M-%S%%-.c ./
Other than replacing space chars, according to Harvey's explanation: "I might suggest adding a semicolon to filter out characters in the Make string that might be illegal in file names"
Sorry for delay in response! :)