Set metadata as "FirstName LastName" from filename "LastName FirstName.jpg"

Started by dmnelson, May 26, 2011, 12:01:32 PM

Previous topic - Next topic

dmnelson

This should be a relatively basic question but I'm not sure how to do it...

I have a bunch of JPEG files that are portraits of people. The filenames are in the form of "lastname firstname.jpg"

Based on that file name, I would like to set some field in the metadata so that it contains "firstname lastname". Or better yet have one field contain the first name and another contain the last name separately.

I don't really care which fields are used to store the names as long as Adobe Bridge can read them when creating a contact sheet and sending it to InDesign.

PS. I'm running Mac OS X

Phil Harvey

Manipulating tag values is not basic, and requires the creation of a user-defined tag.  Here is a config file that will do what you want:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        FirstName => {
            Require => 'FileName',
            ValueConv => '$val=~s/ .*// ? $val : undef',
        },
        LastName => {
            Require => 'FileName',
            ValueConv => '$val=~s/\..*?$//; $val =~ s/.* //; $val',
        },
    },
);

1;  #end


After activating this config file, you can use this command:

exiftool "-sometag<firstname" "-someothertag<lastname" 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 ($).

dmnelson

Perfect! I used the City and Country fields to store the first and last name, then used Bridge to make a contact sheet that uses that metadata as the caption, and it worked exactly how I wanted.
Thank you!