ExifTool Forum

ExifTool => Newbies => Topic started by: ssmith001 on August 23, 2013, 11:35:33 AM

Title: Update subject field w/ filename substring
Post by: ssmith001 on August 23, 2013, 11:35:33 AM
I have a bunch of files that look like this:   84920701068_4006138.tif

I want to update (append) the last 7-digits before the extension (4006138) to the Subject field. I've tried this command but I get a "bad substitution" error.

exiftool "-xmp:subject<${filename;$_=substr($_,-7,4)}" -ext tif /Users/stevesmith/Downloads
Title: Re: Update subject field w/ filename substring
Post by: Phil Harvey on August 23, 2013, 11:40:40 AM
What O/S are you using?  Your command should work for Windows, but you will get "138." written to XMP:Subject.

On Mac/Linux, use single quotes instead of double quotes.

For the last 7 digits of the file name, you should use substr($_,-11,7) (the last 4 characters of FileName are the extension).

- Phil
Title: Re: Update subject field w/ filename substring
Post by: ssmith001 on August 23, 2013, 11:44:42 AM
Mac
Title: Re: Update subject field w/ filename substring
Post by: ssmith001 on August 23, 2013, 11:47:51 AM
I changed it as such and still get the error:

exiftool "-xmp:subject<${filename;$_=substr($_,-7,4)}" -ext tif /Users/stevesmith/Downloads
Title: Re: Update subject field w/ filename substring
Post by: Phil Harvey on August 23, 2013, 12:09:21 PM
You still have double quotes, but you should be using single quotes on the Mac.

- Phil