Editing a metadata field

Started by judyn, March 29, 2012, 11:52:19 PM

Previous topic - Next topic

judyn

I do a number of simple things with exiftool to my images before I load them into Lightroom, but this problem is more complicated than what I usually do.  This time I want to edit an existing field, deleting everything after the first comma, including the comma. 

In other words, Sublocation might contain
Willow City Loop, Fredericksburg, Texas etc

whereas I want it to contain only the proper sublocation information, in this case:  Willow City Loop

All of it after the first section are repeated in the City, State, Country fields.  I can't fix the tool that puts this in the sublocation field, but I can write out the metadata to the files, edit this field, and then read the metadata.  I'm using Windows. 

Phil Harvey

With this config file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        'MySub-location' => {
            Require => 'Sub-location',
            ValueConv => '$val =~ s/,.*//; $val',
        },
    },
);
1;  #end


and this command:

exiftool "-sub-location<mysub-location" FILE

you can do what you want.  (Assuming the tag you want is really "Sub-location", which would be surprising to me because Lightroom prefers XMP and not the old IPTC).

See the sample config file for details about how to activate the configuration file.

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

judyn