Passing tags through 'awk'

Started by Archive, May 12, 2010, 08:54:28 AM

Previous topic - Next topic

Archive

[Originally posted by mquirk on 2008-12-04 14:20:19-08]

I'm using ExifTool to modify the metadata and sort large batches of images.  So far, I love it, apart from a minor quibble: I'd like to copy just part of the file's directory path to the JobID field.

For example, we have a bunch of files stored in subfolders in a folder called "RawImages".  I can do most of what I want with the following command:

Code:
exiftool '-JobID<${directory}' -ext .tif RawImages -r

..but the tag comes out as "RawImages/123456" etc.  I'd like to get just the last part of the directory path - something like you get if it were piped through awk -F'/' '{print $NF}' before assigning the tag.

Is there any way to have the ${directory} variable piped through awk in mid-command?  Or is there an easier way of doing something similar?

Archive

[Originally posted by exiftool on 2008-12-04 15:52:34-08]

There are two ways:

1) "cd RawImages" then run "exiftool *"

2) Create a user-defined tag to process the directory value in
any way you want.  A config file like this will do it:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyDir => {
            Require => 'Directory',
            ValueConv => '$val =~ s{.*/}{}; $val',
        },
    },
);

- Phil

Archive

[Originally posted by mquirk on 2008-12-04 20:27:13-08]

Version 2 worked great, but did need a minor tweak: taking the spaces out from either side of =~

Thanks for the help!

Archive

[Originally posted by exiftool on 2008-12-05 11:21:19-08]

Glad it worked.  The spaces around "=~" are not significant,
so it must have been something else that caused the
problem you observed.

- Phil