1

this question has been answered in a generic way here: https://photo.stackexchange.com/a/38507/9913

In my case I have hundreds of raw image-xmp files in various folders to which I'd like to add (not replace possibly exisitng) keywords that are contained in a text-file. This text-file has 2 columns:

full Path/filename TAB keyword(s), comma separated

I am certain this can be done by means of exiftool. But how?

Someone certainly has done this before, so I hope that special someone will share the working command-line for exiftool.

Thanks for advice and feedback.

1

I believe your CSV file will need a couple alterations. First, I don't think Exiftool will read a tab delimited csv. The docs seem to indicate comma separated only. You could import into Excel or OpenOffice with the tab delimiter set and export a new CSV which should be readable to Exiftool.

Second, the first line needs to needs to have column headers indicating the Tags you want to import. The first column needs to be SourceFile. Your second column could be Keywords (for IPTC:Keywords) or Subject (for XMP:Subject). I'd suggest Subject, as that's the more modern standard. I believe LR will read either and will write both.

After that, the command should be something like
Exiftool -sep ", " -csv=/path/to/file.csv /path/to/target/files
If the files are in multiple directories, just add those directories. You can add -r to recurse. Exiftool should only process those files in the CSV file and are included in the command line directories.

The -sep option indicates the value that should be used to separate each item of the keywords.

Further reading
Exiftool docs on -csv
Exiftool FAQ 26, How do I import information from a database?

  • Thanks. I've read the FAQs. Existing XMP files contain comma separated Keywords in the XMP:Subject field. In CSV file it's easy to replace the TABs with a comma or colon. Regarding the source file: do you mean the XMP or the image file? In my view the source file is the TXT-file containing the full path of the XMP-file (target) in the 1st. column and the value (Keyword) in the 2.column that exiftool should add into XMP:Subject field of the respective target file in 1st.column. So why do I need the '/path/to/target/files'? – snahl Jun 3 '15 at 22:14
  • >In CSV file it's easy to replace the TABs with a comma or colon. Sorry, I'm making assumptions about your CSV. For Exiftool to read it, the second column will have to be encased in quotes. You didn't mention that in your example, which is why I suggested the import/export. To be more explicit, the csv needs to look like this SourceFile,Subject c:\path\to\image.jpg,"keyword 1, keyword 2, keyword 3" – StarGeek Jun 3 '15 at 23:14
  • As for the need for the /path/to/target/files, from the docs "When importing from a CSV file, only files specified on the command line are processed. Any extra entries in the CSV file are ignored." I believe that means that if you have in your csv, for example, one file path is /path/to/target/files/image.jpg and /path/to/other/files/image2.jpg and only /path/to/target/files/ in your command line, image2.jpg will not be processed. – StarGeek Jun 3 '15 at 23:20
  • Thanks again. No worries about the CSV editing. I will start to figure this out. I am certain exiftool has the power to grab the target path and the associated values all from a TXT-file and then write the values the corresponding XMP-file. I will post back once I've got the solution (may take some time). – snahl Jun 4 '15 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.