Copy tag only if it does not exist already

Started by alta, February 24, 2024, 11:36:47 AM

Previous topic - Next topic

alta

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.jpgSo 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?

StarGeek

Try the -wm (-writeMode) option, specifically -wm cg. That will "Create new tags" (c) and "Create new Groups as necessary" (g) but will not write to existing tags.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

alta

Thank you, StarGeek. That solved it and it'll be a very useful option to keep in mind.