ExifTool Forum

ExifTool => Newbies => Topic started by: usagi on January 04, 2015, 04:50:08 AM

Title: Problem with copying + replace tag content
Post by: usagi on January 04, 2015, 04:50:08 AM
Hi,

I am trying to copy content of xmp:HierarchicalSubject field to another field (in this case, Subject) while performing some string substitutions.

This works fine from one liner like:


exiftool "-xmp:Subject<${HierarchicalSubject;s/\|/\//g}"  image.jpg


This replaces every pipe with slash.

When I am trying same by using config file, I can't get ValueConv working properly:


%Image::ExifTool::UserDefined = (

# .....

    'Image::ExifTool::Composite' => {
             MyCreateSubject => {
                       Require => 'HierarchicalSubject',
                       ValueConv => '$val =~ s/\|/\//g; $val',    
             },
     }, 

# ....

);


#------------------------------------------------------------------------------
1; # end



When executing exiftool.exe -config myconfig.txt "-Subject<myCreateSubject"  image.jpg, the result is plain copied value. It seems that I can't get string substitution to work, the output will always be unmodified value of $val.

I have tried also different formats like s#|#/#g with no success.
Title: Re: Problem with copying + replace tag content
Post by: Phil Harvey on January 04, 2015, 08:52:12 AM
Maybe I should put an example of this in the sample config file.  There are various examples (like this) (https://exiftool.org/forum/index.php/topic,3945.msg18390.html#msg18390) on the forum with examples of how to loop through the individual list items in a UserDefined Composite tag definition.

- Phil
Title: Re: Problem with copying + replace tag content
Post by: usagi on January 04, 2015, 09:08:49 AM
Thank you!

That solved the problem :)