Exiftool and CSV file options

Started by graemec, May 16, 2013, 06:09:10 PM

Previous topic - Next topic

graemec

Thanks for providing Exiftool.
I was hoping to use it without bothering the forum, but i hit a snag, and need some advice.
Here's the background - A good friend of mine passed away a while ago and left a collection of around 18,000 images (mostly archaeology related) all in jpg format. The images are arranged in several directories and subdirectories covering region, county, and site eg.
C:\temp2\scotland\Ayrshire\xxxx.jpg
There are seperate captions for most images, but these only exist in an .XLS file (Excel spreadsheet) not in the jpg files themselves. My thought was to save the XLS data in a CSV file and use Exiftool to batch insert the captions into the XMP:description tag for each jpg.
After reading the exiftool documentation i realised there might be a problem because only the image file name was listed in the XLS file, ie not its full directory path.  A section of the CSV file looked like this,
SourceFile,Description
ellingham-a.04.am.berwmus.jpg,Ellingham-A
weetwood_c-l.04.am.berwmus.jpg,Weetwood Cairn
ringses.1990.hewitt.berwmus.jpg,"The Ringses 1990"

I decided to give it a try any way using this command line -
exiftool  -csv=foto1.csv -r -xmp:description -ext jpg  c:\temp2
Exiftool ran and seached all the directories but obviously could not find a match in the CSV file for the full directory paths it encountered to the actual image files.
I'm not sure if there is a solution to this - can Exiftool ignore the filepath and just grab the filename?
or is there another way to perform this task? -other than manually typing in 18,000 captions!
Thanks

Phil Harvey

If there are no directories in the CSV, then you would need to "cd" to each directory separately and run exiftool from there:

1) cd C:\temp2\scotland\Ayrshire\

2) exiftool -csv=c:\some_directory\my.csv *.jpg

In this way, the file names entered on the command line will match the SourceFile column in the CSV file.

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

graemec

thanks for the pointer
I just tried this on a couple of directories and it worked ok on one, but the other caused exiftool to stop on an error because it could not match a file name to the csv list.  a bit of editing the cvs file fixed this.
There are quite a few more directories to sort, but even this little bit of editing is better than typing in 1000's of captions.

Thanks again
Graeme

davidstirling

Hello, I'd like to re-open this thread to make sure nothing has changed. I have images in many nested folders and I was hoping to apply metadata via a CSV file. However, the CSV SourceFile row contains the file name only, not the path. Is there no way to have exiftool search folders recursively but only use the file name? For now my solution is to move everything into one folder, apply the metadata, then re-organize the files back into folders using Bridge by filtering the metadata. Thank you for creating exiftool; it is fantastic.

Phil Harvey

This situation hasn't changed, but since this post a new HardLink option has been added that may be useful to you.  The steps with this function would be:

1. "cd" to a temporary directory

2. Create hard links in the temporary directory to all of your images files:

  exiftool -hardlink=%f.%e -r DIR

  (where DIR is the directory containing your images)

3. Update the metadata in your images files using the hard-linked files:

  exiftool -csv=CSVFILE .

  (where CSVFILE is the CSV file with a SourceFile column that contains file names without a directory)

4. delete all hardlinks in the temporary directory

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