How do i replace a string with a string from another tag?

Started by Toms, July 21, 2023, 06:15:08 AM

Previous topic - Next topic

Toms

Hi!

I've tried to make IPTC Copyright notice «© Organisation, 2004.» look like «© Author, 2004., © Organisation, 2004.» by doing this:
exiftool "-iptc:CopyrightNotice<${iptc:CopyrightNotice;s/Organisation/${iptc:Credit}/}, ${iptc:CopyrightNotice}" a.jpgbut it didn't work.
What should I do instead?

Phil Harvey

Interesting construct, but ExifTool doesn't support tag variables within advanced formatting expressions.  Instead, try this:

exiftool "-iptc:CopyrightNotice<${iptc:CopyrightNotice;my $credit=$self->GetValue('Credit') or $_=undef, return;s/Organisation/$credit/}, ${iptc:CopyrightNotice}" a.jpg

Also, in the future "it didn't work" isn't very helpful.  The command should have given his warning which would have been useful to know:

Warning: syntax error for 'iptc:CopyrightNotice' - a.jpg
- 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 ($).

Toms

Oh, wow, thank You, Phil! I would never figure it out! It works  :)

StarGeek

Quote from: Phil Harvey on July 21, 2023, 08:13:16 AMAlso, in the future "it didn't work" isn't very helpful.  The command should have given his warning which would have been useful to know:

The only answer to "it didn't work" is "it works here" (though yes, it isn't true in this situation).  I'm still trying to come up with a more polite way of saying things like that as a standard response template.
"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