ExifTool Forum

ExifTool => Newbies => Topic started by: twhite on November 14, 2017, 05:14:18 AM

Title: Default value for a missing tag
Post by: twhite on November 14, 2017, 05:14:18 AM
I would like to add a default value for a missing tag. I this case is the LensID.  This is my code:


exit_param="-m -r -progress: "
camera='${Exif:Model;s/EOS//;s/910G/910F/;s/920G/910F/;s/PowerShot//;s/DIGITAL //;s/ IS//;tr/ /_/;s/__+/_/g}'
lens='${LensID;s/ f\/.*$//;s/ DC HSM//;s/Unknown/Embedded/;tr/ /_/}'
ms='${SubSectimeOriginal;$_.=0 x(3-length)}'
suffix="-${ms}__${camera}~~${lens}"'%+c.%le'
suffix_noms="__${camera}~~${lens}"'%+c.%le'

exiftool -ext jpg -ext JPG ${exit_param} -d "%Y-%m-%d_%H-%M-%S" '-testname<${datetimeoriginal}'"${suffix}"  -if '${Make} eq "NIKON CORPORATION"'  .
exiftool -ext jpg -ext JPG ${exit_param} -d "%Y-%m-%d_%H-%M-%S" '-testname<${filemodifydate}'"${suffix_noms}" '-testname<${createdate}'"${suffix_noms}" '-testname<${datetimeoriginal}'"${suffix_noms}"  -if '${Make} ne "NIKON CORPORATION"'  .


some of the results:
2017-10-20_08-34-10-370__NIKON_D7200~~Sigma_18-35mm_F1.8.jpg
2011-01-01_01-14-29__Canon_SD800~~Embedded_4-17mm.jpg

2000-07-24_20-36-00__C2500L~~.jpg
2000-04-08_18-15-19__C2000Z~~.jpg'

How can I set a default value for example 'Embedded'  when the value of LensID is missing?
Title: Re: Default value for a missing tag
Post by: Phil Harvey on November 14, 2017, 07:04:10 AM
Just repeat the argument that uses LensID earlier on the command line, with the default value in place of $LensID.  If LensID exists, then the default argument will be overridden by the subsequent assignment.

- Phil