ExifTool Forum

General => Metadata => Topic started by: gagadada on November 28, 2014, 05:08:40 AM

Title: Large text file => adding meta info to files
Post by: gagadada on November 28, 2014, 05:08:40 AM
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  :-)

Title: Re: Large text file => adding meta info to files
Post by: Phil Harvey on November 28, 2014, 07:32:15 AM
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
Title: Re: Large text file => adding meta info to files
Post by: gagadada on November 28, 2014, 07:36:04 AM
Hi Phil,

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

Cheers!
Title: Re: Large text file => adding meta info to files
Post by: Phil Harvey on November 28, 2014, 09:43:23 AM
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
Title: Re: Large text file => adding meta info to files
Post by: gagadada on November 28, 2014, 09:45:06 AM
Awesome! Thanks for your kind support!!
Title: Re: Large text file => adding meta info to files
Post by: gagadada on November 29, 2014, 11:32:27 AM
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!
Title: Re: Large text file => adding meta info to files
Post by: Phil Harvey on November 29, 2014, 02:30:04 PM
Great.  Glad it worked for you.

- Phil