ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: LookTouch Photo on September 25, 2020, 01:52:39 PM

Title: Create filename (sub)string based on a tag mapping?
Post by: LookTouch Photo on September 25, 2020, 01:52:39 PM
I am copying files with this command (OS W10)

exiftool -d "\%Y\%m\%d_%H%M_%S" "-filename<targetdir${createdate}${FileSequence;$_%=100;$_=sprintf('%02d',$_ )}_C5.%e" "sourcedir"

This created files e.g. 
21_1536_2905_C5.ARW
21_1537_5506_C5.CR2
21_1538_0107_C5.JPG
etc.

(of course in directory 2020\09\)

Is it possible to dynamically assign the _C5 part (aka CamID) based on the value of the -model tag and a mapping table ?
For example:

-model tag               CamID
EOS-1Ds Mark III   _C2
ILCE-7RM3             _C5
Nexus 6P               _C6

Desired result:
21_1536_2905_C5.ARW
21_1537_5506_C2.CR2
21_1538_0107_C6.JPG

Currently I am using a workaround based on multiple calls to exiftool with e.g. -if "$Model = 'ILCE-7RM3'" and hardcoding the CamID, in this case  "_C5" in the command.

Bonus challenge :-)
For unknown models (tag value not in the table) _XX should be assigned.
Title: Re: Create filename (sub)string based on a tag mapping?
Post by: Phil Harvey on September 25, 2020, 05:06:42 PM
There are a number of threads discussing this already.  Here is one (https://exiftool.org/forum/index.php?topic=8980.0).

In your case you would use:

            OTHER => sub { return "XX" },

- Phil
Title: Re: Create filename (sub)string based on a tag mapping?
Post by: LookTouch Photo on September 25, 2020, 06:11:53 PM
Thanks for the pointer! And for creating such a powerful tool!