Large text file => adding meta info to files

Started by gagadada, November 28, 2014, 05:08:40 AM

Previous topic - Next topic

gagadada

Hi guys,

I have some 50'000 photos in various folders. Unfortunately, they have no meta information. However, I have a text file with all the meta information. Is there a neat way to batch process the information into the files?

Text file structure:
Filename (no folder info, just the filename) | Description Flag | Description | Keyword Flag | Keywords

Any suggestion is appreciated  :-)


Phil Harvey

This will require either some scripting or some manual intervention, but it shouldn't be too difficult.

Maybe something like this:

1) Get a list of all files and their directories using ExifTool:

exiftool -filename -directory -T DIR | sort > out1.txt

(where "DIR" is the name of the directory containing the images.  Hopefully your system has a "sort" utility.  Otherwise you'll have to sort this yourself later in the spreadsheet.)

2) Sort your text file too:

sort textfile.txt > out2.txt

3) load them both into a spreadsheet, and match the exiftool output lines to the files in your text file (you'll have to resolve problems due to duplicate, missing and extra file names).

4) combine the directory/filename into a single column with a "/" between them (I'm not sure how to do this in the spreadsheet, so I will be adding a "FilePath" tag to the next release to make this easier)

5) Rearrange the columns to be the same order as the output of this command:

exiftool -csv -xmp:description -xmp:subject DIR

6) Export the spreadsheet to a CSV file called "out.csv".

7) Run this command to import the new descriptions/keywords:

exiftool -csv=out.csv DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gagadada

Hi Phil,

Thanks for the very fast reply! I will try that and report back (but I will need probably some days..).

Cheers!

Phil Harvey

I should have mentioned that the column headings of the CSV file must be exactly the same as the -csv output from step 5.

Good luck.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gagadada


gagadada

#5
Ok, thanks for your remark on the headings...I needed a couple of faulty tries until I got it...  ;D

So the CSV structure (and exact heading names) is: SourceFile, description, subject

And with "-r" and "-overwrite_original" I made it do the whole thing recursively and without creating a backup file.

Many thanks Phil!

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).