ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Invindicator on November 08, 2018, 06:54:37 AM

Title: Condition Testing on -p Flag
Post by: Invindicator on November 08, 2018, 06:54:37 AM
Hi all,

Is it possible to print a default value where a tag doesnt exist when using the -p flag
For example the subsectimeoriginal tag doesnt exist in mp4 files, so when running my script I would like exiftool to print a 000 in place of the subsectimeoriginal tag

Here is one thing I tried, not sure if on the right track or there is an easier way to do this or not
exiftool -m -p "${subsectimeoriginal;s//0000/}" "vid0000.mp4"

Regards,
Nick
Title: Re: Condition Testing on -p Flag
Post by: Phil Harvey on November 08, 2018, 07:18:35 AM
Hi Nick,

The advanced formatting expression isn't evaluated for a missing tag.

But you can set a value to be used for all missing tags, something like this:

exiftool -m -f -api missingtagvalue=0000 -p "$subsectimeoriginal" FILE

To quote the -p option documentation:

            If a specified tag does not exist, a minor warning is issued and
            the line with the missing tag is not printed.  However, the -f
            option may be used to set the value of missing tags to '-' (but
            this may be configured via the MissingTagValue API option), or the
            -m option may be used to ignore minor warnings and leave the
            missing values empty.

- Phil
Title: Re: Condition Testing on -p Flag
Post by: Invindicator on November 09, 2018, 06:34:40 PM
Thanks Phil

Is there any way to insert different default values for different tags however if, say for example, there werre multiple missing tages in the one -p statement

Thanks
Nick
Title: Re: Condition Testing on -p Flag
Post by: Phil Harvey on November 10, 2018, 07:42:59 AM
Hi Nick,

For this you could go to a user-defined Composite tag which is based on all of the tags you want extracted.  This is a bit more complex but you would have complete control of the output formatting.

- Phil

Title: Re: Condition Testing on -p Flag
Post by: Invindicator on November 10, 2018, 06:47:06 PM
Awesome! Thanks so much