I have a rather complex command to import data to my images written to a spreadsheet:
TZ_OFFSET="+01:00"; CSV=CSVFILE
exiftool -api MissingTagValue=- -csv="$CSV" -f -v2 -G -sep ', '\
-EXIF:SubSecTimeOriginal=0 -EXIF:SensitivityType=Unknown -EXIF:LightSource=0 -EXIF:SceneType= -EXIF:ExposureMode= -EXIF:SceneCaptureType= -EXIF:GainControl= -EXIF:SubjectDistanceRange=Unknown -EXIF:SerialNumber= -XMP:SerialNumber= -XMP:LensID= -XMP:ImageNumber= -XMP:ApproximateFocusDistance=\
'-EXIF:Artist<$XMP:Creator' '-EXIF:Copyright<$XMP:Rights' ... and many more ...\
FILES
The second last line of my command copies some tags to other tags with the same meaning to make the data more compatible (as known from Lightroom, for example). Additionally I support the explicit removal of tags (if information is missing) with -f by typing '-' inside a cell in my spreadsheet. But, for example '-' for XMP:Creator (within CSV) will only cause XMP:Creator to be removed, while EXIF:Artist becomes '-'. Same result with
'-EXIF:Artist<XMP:Creator'
I think this either a bug or there is a good reason that this does not work as expected.
This works for me:
> cat a.csv
SourceFile,EXIF:Artist,XMP:Creator
a.jpg,-,-
> exiftool a.jpg -exif:artist=me -xmp:creator=you
1 image files updated
> exiftool a.jpg -G -exif:artist -xmp:creator
[EXIF] Artist : me
[XMP] Creator : you
> exiftool a.jpg -csv=a.csv -f
1 image files updated
> exiftool a.jpg -G -exif:artist -xmp:creator
> exiftool a.jpg -exif:artist=me -xmp:creator=you
1 image files updated
> exiftool a.jpg -G -exif:artist -xmp:creator
[EXIF] Artist : me
[XMP] Creator : you
> exiftool a.jpg -csv=a.csv -f -api missingtagvalue=-
1 image files updated
> exiftool a.jpg -G -exif:artist -xmp:creator
>
But maybe the problem is your second-last line, which will override the -csv input for those tags and copy the existing values of the other tags. Is this what you want?
- Phil
I don't understand your answer since you don't use the redirection syntax at all. But this is what I want to point to.
The tags I copy to may already be set in the image but are never included in the CSV. The copying works fine with exception of '-' as content of XMP:Creator (or any other tag) which is, along with the option `-f` interpreted as "Remove this tag". And this only works for the original tag XMP:Creator, but it would be great if removal of tag XMP:Creator could be somehow re-applied to a tag EXIF:Artist where XMP:Creator is copied to. At least if '-' is interpreted as removal for tag XMP:Creator, then if EXIF:Artist copies content of tag XMP:Creator, '-' should be replaced by ''.
Sorry, because I am a bit confused if this works at all: whether exiftool redirects tag as they were recently set with -csv or if it takes the old value from the file.
https://exiftool.org/forum/index.php?topic=10912.0
The source of copied tags is always the original file.
- Phil
Now I can answer my question after I learned about -execute. To repeat the exact same operation of tag A to tag B (copying A or removing A), two steps are needed:
-IPTC:ObjectName= -execute\
'-IPTC:ObjectName<$XMP:Title'
Without the first step, -IPTC:ObjectName would have a deprecated value if -XMP:Title was not contained in the CSV or was "-".
I would have thought that -execute was not necessary here. You should be able to do this:
exiftool -IPTC:ObjectName= -csv=some.csv -f FILE
which will delete IPTC:ObjectName either if it doesn't exist in the CSV or has a value of "-" in the CSV file.
(maybe reading FAQ 22 (https://exiftool.org/faq.html#Q22) may help here?)
- Phil
I believe the problem is that
IPTC:ObjectName is not set in the CSV file but
XMP:Title is set. Which is why
ObjectName needs to be copied afterwards.
Quote from: Andi on March 03, 2020, 10:57:51 PM
Sorry, because I am a bit confused if this works at all: whether exiftool redirects tag as they were recently set with -csv or if it takes the old value from the file.
If you think about it, how would you swap two tags if it didn't use the original value. For example:
exiftool "-Headline<Description" "-Description<Headline" file.jpgwould be impossible if it didn't copy from the original values.
Quote from: Phil Harvey on March 08, 2020, 09:27:06 AM
I would have thought that -execute was not necessary here. You should be able to do this:
exiftool -IPTC:ObjectName= -csv=some.csv -f FILE
which will delete IPTC:ObjectName either if it doesn't exist in the CSV or has a value of "-" in the CSV file.
(maybe reading FAQ 22 (https://exiftool.org/faq.html#Q22) may help here?)
The FAQ describes what you already told me:
QuoteWhen copying tag values, adding to lists, or shifting date/time values, the source value is always the original value found in the file, regardless of any previous assignments.
My exiftool command has several parts, and all tags are given with their directory (as shown with `-G`):
0)
exiftool1) Reset some tags that make no sense for my images or are private
2) Reset all tags that
can but must not be part of a spreadsheet. You could as well omit this, but then I risk that old data persists.
3) Reset all tags that will inherit from those tags in (6):
-EXIF:Artist= EXIF:Copyright= -EXIF:FocalLengthIn35mmFormat= ...4) First
-execute Probably not needed because
-csv=... overwrites all the tags it contains.
5)
-csv="$CsvInputFile" -execute6) Inherit from spreadsheet values. Tags set here must have been removed in step (3).
'-EXIF:Artist<$XMP:Creator' '-EXIF:Copyright<$XMP:Rights' ...7)
-common_args -api MissingTagValue=- -f -v$V -G -sep ', ' IMAGESI guess I can remove (4) now.
QuoteIf you think about it, how would you swap two tags if it didn't use the original value. For example:
exiftool "-Headline<Description" "-Description<Headline" file.jpg
would be impossible if it didn't copy from the original values.
This is a good point, programming languages could learn from it :D
It would only be possible by using a yet unused tag and with a slow `-execute` in between.