Hi, I'm using ExifTool to record the orginal filenames of images in the OriginalFilename tag and trying to come up with a command that doesn't change the value of the tag when it's run again on a file that was renamed. This example from the documentation seems perfect for that purpose:
exiftool -comment-= -comment='new comment' a.jpg
Write a new comment only if the image doesn't
have one already.
However, when copying a tag instead of assigning a literal value, the tag gets overwritten if it already exists.
For example:
exiftool -OriginalFilename old.jpg
exiftool -OriginalFilename-= '-OriginalFilename<Filename' old.jpg
exiftool -OriginalFilename old.jpg
Original File Name : old.jpg
So far, so good. But then:
mv old.jpg new.jpg
exiftool -OriginalFilename-= '-OriginalFilename<Filename' new.jpg
exiftool -OriginalFilename new.jpg
Original File Name : new.jpg
Is this expected? What am I missing, and how can I keep the tag value unchanged once it exists?
Try the -wm (-writeMode) option (https://exiftool.org/exiftool_pod.html#wm-MODE--writeMode), specifically -wm cg. That will "Create new tags" (c) and "Create new Groups as necessary" (g) but will not write to existing tags.
Thank you, StarGeek. That solved it and it'll be a very useful option to keep in mind.