Write metadata for file to IPTC one at a time matched by filename

Started by hrgoldstein, August 10, 2017, 04:29:31 PM

Previous topic - Next topic

hrgoldstein

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!!

Phil Harvey

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

hrgoldstein

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!

Phil Harvey

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

StarGeek

You could use something like CSVKit 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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

hrgoldstein

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?

Phil Harvey

They get written to the tag specified in the csv column header.

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