ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Beholder3 on July 24, 2013, 07:24:31 AM

Title: Sequence of commands for renaming?
Post by: Beholder3 on July 24, 2013, 07:24:31 AM
Hi,
I currently use this nice little Lightroom plugin to run exiftool on exported pictures:
https://chaoliu12.wordpress.com/fullmetaexport-lightroom-plugin/

Before putting anything there I test it out using exiftoolGUI.

What I want:
I do want to first add/ change some field data and then rename the file based on these fields. I want to do this in a single exiftool command line.

Here is what I try:
-exif:LensModel<makernotes:LensType -XMP:Lens<makernotes:LensType -exif:LensInfo<LensID -exif:LensMake<LensManufacturer -exif:FocalLength<copy2:FocalLength -filename<"$focallength F$FNumber $LensModel.%e"

Somehow it doesnt work with the LensModel.

Question 1:
Is there anything about the order of commands to make it work?

Question 2:
Is there any way to put special characters like "-" into the changed filename?
Title: Re: Sequence of commands for renaming?
Post by: Phil Harvey on July 24, 2013, 07:41:00 AM
Quote from: Beholder3 on July 24, 2013, 07:24:31 AM
Question 1:
Is there anything about the order of commands to make it work?

The expressions always work on the values of the tags in the original file.  To do what you want requires 2 commands, but you can do this in a single command line by leveraging the -execute option.

QuoteQuestion 2:
Is there any way to put special characters like "-" into the changed filename?

The dash is only a problem if you want it right after a tag (because it is a valid character in a tag name).  To get around this, put braces around the tag names:

-exif:LensModel<makernotes:LensType -XMP:Lens<makernotes:LensType -exif:LensInfo<LensID -exif:LensMake<LensManufacturer -exif:FocalLength<copy2:FocalLength -execute -filename<"${focallength}-F${FNumber}-$LensModel.%e"

- Phil
Title: Re: Sequence of commands for renaming?
Post by: Beholder3 on July 24, 2013, 10:00:27 AM
Thanks for the help and explanations.
I still seem unable to get this to work.

On a Pentax lens I get the following error:
Quote0 image files updated
    1 files weren't updated due to errors
No file specified
Warning: Error creating './16.0 mm-F8.0-smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM.DNG' - ./test.DNG
<-END-

On a Canon lens I get the funny effect that the first part of the intended filename actually is created as folder and within this the file is moved with the second part of the new filename. The cut is done where the Canon lens name has the "/" for the FNumber, which is expressed as "f/2.8" there whereas you create the Pentax ones as F2.8.

I am guessing wildly that the Pentax lens renaming has issues with the "*" in the name.

Consequently I now need to ask if there is any way to just ignore special characters for file renaming.


Title: Re: Sequence of commands for renaming?
Post by: Phil Harvey on July 24, 2013, 10:12:40 AM
Right.  File names have special characters like "*" and "/".  You can filter these out by adding a semicolon in the braces.  Also, I think I should have added a -common_args to fix the "No file specified" problem:

-exif:LensModel<makernotes:LensType -XMP:Lens<makernotes:LensType -exif:LensInfo<LensID -exif:LensMake<LensManufacturer -exif:FocalLength<copy2:FocalLength -execute -filename<"${focallength}-F${FNumber}-${LensModel;}.%e" -common_args

- Phil
Title: Re: Sequence of commands for renaming?
Post by: Beholder3 on July 24, 2013, 10:41:17 AM
Thanks.  :)

Now it's working.
Title: Re: Sequence of commands for renaming?
Post by: Beholder3 on September 08, 2013, 04:51:03 AM
One follow up question on this renaming:
Is there a way to append numbering to the filenames if the filename already exists?

Example: I have shot two photos with 50mm F2 LensA. Currently just the first photo will be renamed and the other one will stay the original. It would be nice if in this case the action would result in "50mm F2 LensA" and "50mm F2 LensA_2" or similar.
Title: Re: Sequence of commands for renaming?
Post by: Phil Harvey on September 08, 2013, 08:05:16 AM
To do exactly what you ask, add %+nc to the file name.  See the -w option documentation for more possibilities.

- Phil