Pattern to return a default value when a certain tag is missing

Started by metadataddicted, Today at 03:54:15 PM

Previous topic - Next topic

metadataddicted

Hi all,
I am a total newbie, started studying this valuable tool a few days ago.

I was wondering if there is a pattern or a snippet which I can use to insert one part of a filename when the corresponding tag is missing.

Here is the case:
I would like to name my files with the following scheme:

%Y%m%d-%H%M%S_%MS#[TAKER_ID];%MAKE;%MODEL;%OP

so, for example:
20100216-120330#PG;HTC;HTC HD2 T8585;IMAG0081#HD2.JPG

This is the command line I use in a bat file in windows 11:
.\exiftool.exe -P -m -overwrite_original_in_place -wm cg "-XMP-xmpMM:PreservedFileName<${filename;$_ = undef if $self->GetValue('PreservedFileName')}"  "-filename<${datetimeoriginal;DateFmt('%%Y%%m%%d-%%H%%M%%S')}${subsectimeoriginal;$_='0'x(3-length).$_;$_='_'.$_}${offsettimeoriginal;$_=substr($_,0,3)}#PG;${make};${model};%%f.%%ue" .

Unfortunately, among the variety of devices and applications, there are some files where not all the tags are defined, such as those coming from whatsapp on android.

For these cases, I get for example:
#PG;;;IMG-20241118-WA0003#GalaxyS22U.JPG

I was wondering if there is some trick I can use to fill a default value with the missing tags, such as maker and model. I will figure out how to deal with the missing DateTimeOriginal in a different way.

It would be useful something like
-'filename<Helper(TAG;DEFAULT_VALUE_IF_TAG_IS_UNDEF)'

I tried to play with some of the patterns I found around on the forum and on the documentation but I can't figure out anything similar.

I guess the if construct is not an option since I would like to cover several tags in the filename with a unique line.

In your experience is there some way to deal with this issue?

Thank you in advance.