Redirect tags taken from CSV to other tags

Started by Andi, March 03, 2020, 10:56:06 PM

Previous topic - Next topic

Andi

exiftool -csv="CSVFILE" -f -v2 -G -sep ', '\
    -tagsFromFile @ '-EXIF:ImageDescription<$XMP:Description' '-IPTC:Caption-Abstract<$XMP:Description'\
    FILES


CSVFILE contains XMP:Description that I want to copy to other tags. The problem is that exiftool uses the old value from the image file (FILES) instead of the new value in CSVFILE
How can $XMP:Description refer to the value imported from the CSV?

Phil Harvey

You can't do this in a single step.  But you can do 2 commands in one line, like this:

exiftool -csv="CSVFILE" -f -v2 -sep ', ' -execute \
    '-EXIF:ImageDescription<$XMP:Description' '-IPTC:Caption-Abstract<$XMP:Description'\
    -common_args FILES


- Phil

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Andi

Thanks, this works with a minor correction:

exiftool -csv="CSVFILE" -f -v2 -sep ', ' FILES -execute ... FILES

An additional thing I want to do is appending some strings that I define as variables:

TO_DESCRIPTION=' APPENDED'
TZ_OFFSET="+05:00"
CSV=CSVFILE
exiftool -m -api MissingTagValue=- -csv="$CSV" -f -v2 -G -sep ', ' FILES -execute\
    '-IPTC:TimeCreated<${IPTC:TimeCreated}'"$TZ_OFFSET" '-XMP:Description<$XMP:Description'"$TO_DESCRIPTION" FILES


This works fine for -XMP:Description – my variable is appended, but I cannot build the time string in the same way by appending a TZ offset (which may not be the one of my system).

Exiftool ignores the string I have built and instead uses my system's timezone (without adapting the time):

"IPTC:TimeCreated": "16:00:00+01:00"

Phil Harvey

Quote from: Andi on March 04, 2020, 09:28:59 AM
Thanks, this works with a minor correction:

exiftool -csv="CSVFILE" -f -v2 -sep ', ' FILES -execute ... FILES

My command should have worked.  The -common_args option should apply FILES to both commands.

QuoteAn additional thing I want to do is appending some strings that I define as variables:

TO_DESCRIPTION=' APPENDED'
TZ_OFFSET="+05:00"
CSV=CSVFILE
exiftool -m -api MissingTagValue=- -csv="$CSV" -f -v2 -G -sep ', ' FILES -execute\
    '-IPTC:TimeCreated<${IPTC:TimeCreated}'"$TZ_OFFSET" '-XMP:Description<$XMP:Description'"$TO_DESCRIPTION" FILES


This works fine for -XMP:Description – my variable is appended, but I cannot build the time string in the same way by appending a TZ offset (which may not be the one of my system).

Exiftool ignores the string I have built and instead uses my system's timezone:

"IPTC:TimeCreated": "16:00:00+01:00"

You must strip the old time zone before adding a new one:

'-IPTC:TimeCreated<${IPTC:TimeCreated;s/[-+].*//}'"$TZ_OFFSET"

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Andi

2:0 for you!

Thank you for this great tool and for helping out people using it!