ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Toms on July 21, 2023, 06:15:08 AM

Title: How do i replace a string with a string from another tag?
Post by: Toms on July 21, 2023, 06:15:08 AM
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?
Title: Re: How do i replace a string with a string from another tag?
Post by: Phil Harvey on July 21, 2023, 08:13:16 AM
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
Title: Re: How do i replace a string with a string from another tag?
Post by: Toms on July 21, 2023, 08:39:52 AM
Oh, wow, thank You, Phil! I would never figure it out! It works  :)
Title: Re: How do i replace a string with a string from another tag?
Post by: StarGeek on July 24, 2023, 10:58:29 AM
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.