ExifTool Forum

General => Metadata => Topic started by: hrgoldstein on August 10, 2017, 04:29:31 PM

Title: Write metadata for file to IPTC one at a time matched by filename
Post by: hrgoldstein on August 10, 2017, 04:29:31 PM
I have need to write metadata from an Excel spreadsheet  (or CSV file) one at a time after capture to a TIFF file based on the filename, which will be a column in the spreadsheet.  I know EXIFTool can do this in bulk but how about a script or command to look in the CSV for the filename indicated copy and paste this in a popup the script uses or point at the file itself first) and then write specified column values to specified IPTC fields for that file.  Thanks in advance!!
Title: Re: Write metadata for file to IPTC one at a time matched by filename
Post by: Phil Harvey on August 11, 2017, 07:18:47 AM
ExifTool will look in the CSV file for the row with the specified file name (matching the "SourceFile" entry in the first column).  The only trick then is getting the name of the file you want updated onto the exiftool command line.  I can't help with that.

- Phil
Title: Re: Write metadata for file to IPTC one at a time matched by filename
Post by: hrgoldstein on August 12, 2017, 04:10:09 PM
Figured out how to get name of the file and pass it on as such:

/usr/local/bin/exiftool -csv=/Users/account_name/Desktop/metadata.csv " & pathName

How do I specify the columns I want from the CSV and the IPTC fields I want to write the data to in the argument?

Thanks again!
Title: Re: Write metadata for file to IPTC one at a time matched by filename
Post by: Phil Harvey on August 12, 2017, 05:56:48 PM
Currently all of the columns get written.

- Phil
Title: Re: Write metadata for file to IPTC one at a time matched by filename
Post by: StarGeek on August 12, 2017, 06:07:35 PM
You could use something like CSVKit (https://csvkit.readthedocs.io/en/1.0.2/) to slice out the columns you want. 

I haven't tested this, but I would think the command would be something like this:

"exiftool -csv=- " & pathName & " | csvcut -c SourceFile,Caption-Abstract,Keywords /Users/account_name/Desktop/metadata.csv"

In this case, csvcut would keep only the columns you wanted and pipe them through to exiftool.  -csv=- would then read from the piped data.
Title: Re: Write metadata for file to IPTC one at a time matched by filename
Post by: hrgoldstein on August 12, 2017, 09:01:58 PM
Thank you.  I can probably have the CSV file already prepped just with the columns I want.  Where would they get written; can I control what IPTC fields, for example, they get written to?
Title: Re: Write metadata for file to IPTC one at a time matched by filename
Post by: Phil Harvey on August 20, 2017, 09:17:03 PM
They get written to the tag specified in the csv column header.

- Phil