News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Problem with copying + replace tag content

Started by usagi, January 04, 2015, 04:50:08 AM

Previous topic - Next topic

usagi

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.

Phil Harvey

Maybe I should put an example of this in the sample config file.  There are various examples (like this) on the forum with examples of how to loop through the individual list items in a UserDefined Composite tag definition.

- 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 ($).

usagi