Exiftool rename example with other than date tags

Started by Archive, May 12, 2010, 08:53:54 AM

Previous topic - Next topic

Archive

[Originally posted by bmcent1 on 2006-04-22 17:43:48-07]

Can anyone give an example of renaming files using multiple tags?

I would like to bulk rename files from a series of test shots into this format:

  $Lens-$Aperture-$FocalLength-$FocusDistance-%Y%m%d_%H%M%S.%%e

So far, I can't figure out how to combine more than one tag to form a file name. I can rename based on CreateDate or ShutterSpeed for example, but not both. I'm not sure what syntax to use.

A related question is how to rename based on CreateDate AND SubSecTime.

Thanks for any ideas!

Archive

[Originally posted by bmcent1 on 2006-04-23 15:40:23-07]

I hope someone has a better solution, but in case there are no responses and someone else has the same quesiton, here is what I did for my specific case:

Code:
for FILE in `ls *NEF`; \
  do RENAMETO=`exiftool -t -s -Lens -Aperture -FocalLength -FocusDistance -CreateDate -d \
    "%Y%m%d_%H%M%S" -SubSecTime $FILE | \
  awk -F" " '{print $2}'|tr -d '[a-z]'| \
  tr '\n' ' '| \
  awk -F" " '{print $1":f"$2":"$3"mm:fd"$4"m:"$5"_"$6".NEF"}'`; \
  exiftool -filename=$RENAMETO $FILE; \
done

Run at your own risk. It worked for my limited purpose. YMMV.

The above could be in a a little shell script but can actually be copy and pasted directly to the command line. If run from a directory containing *.NEF (Nikon RAW format files), it will rename them similar to the following:

  17-55:f4.0:55.0mm:fd0.40m:20060416_161028_50.NEF

Corresponding to Lens focal length range, aperture used, focal length used, focus distance used, date image created plus subsecond time (in case of autowinder and multiple shots in one second.)

Archive

[Originally posted by exiftool on 2006-05-01 15:15:13-07]

Right now there is no easy way to do what you want, however I've had a few requests to do similar things so perhaps I will add this feature to an upcoming version.  Maybe a new assignment operator which allows you to embed tag names in the value string, something like this:

Code:
exiftool -d "%Y%m%d_%H%M%S" -filename~='$lens:f$aperture:${focallength}mm:fd${focusdistance}m:${createdate}_$subsectime.NEF'

The main concern is that this technique still lacks the flexibility to be able to format individual tag values, so it will never be as good as what you can do with a script.  However, maybe it is good enough for most purposes.

Archive

[Originally posted by exiftool on 2006-06-07 17:43:12-07]

I have just released ExifTool 6.23 with this feature.  You can now use an expression instead of a simple tag name with the -tagsFromFile option.  The syntax isn't quite as I outlined before though, and in fact I just use the same syntax as the tagsFromFile redirection feature.  For example, this will do what you were talking about:

Code:
exiftool -d "%Y%m%d_%H%M%S" '-filename<$lens:f$aperture:${focallength}mm:fd${focusdistance}m:${createdate}_$subsectime.NEF' -ext nef DIR

Sorry for the delay, but I couldn't think of any way to make this more powerful without over-complicating the interface, so I finally gave in and took the simple route.  So basically, tag names are expanded in the expression to the right of the '<' symbol if it contains any '$' symbols.