Author Topic: Problem with copying + replace tag content  (Read 1294 times)

usagi

  • Newbie
  • *
  • Posts: 2
Problem with copying + replace tag content
« 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:

Code: [Select]
%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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16724
    • ExifTool Home Page
Re: Problem with copying + replace tag content
« Reply #1 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) 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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

usagi

  • Newbie
  • *
  • Posts: 2
Re: Problem with copying + replace tag content
« Reply #2 on: January 04, 2015, 09:08:49 AM »
Thank you!

That solved the problem :)