Best method to generate a batch update

Started by mbuzina, June 08, 2021, 09:50:04 AM

Previous topic - Next topic

mbuzina

I am looking on preserving some data from a photo management application (Synology Moments), which will be replaced by another app which lacks some support (Synology Photos, no Subject Recognition anymore).I have some commands that extracts the keyword data for each file from the database, I want to use this to generate a script that, if possible works efficiently as it will have to update 150 K files or so (yes, they do have a backup).

What would be the best way to create such a batch? Does exiftool have a way to input tags from file for many different files (I have not found that in documentation and forum)? Should I generate perl commands?

What I do have is a list with "filename", "Keyword A, Keyword B, Keyword C" for each file I want to update.

Thanks for your help!

Phil Harvey

See FAQ 26.

I think you want to use CSV format.  All you should need to do is add a heading row: SourceFile,Subject

(assuming you want to write the keywords to XMP:subject)

Also, you should add -sep ", " to the command to split the keywords into individual entries.

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

mbuzina

Sounds great. So I setup a csv file as follows:
DourceFile,Subject
"/photo/holidays/2020-06-spain/IMG1234.jpg","Beach, Volleyball"
"/photo/holidays/2020-06-spain/IMG1235.jpg","Sea, Boat"
...


and the command would be:
exiftool -sep ", " -tagsFromFile myexporteddata.csv .

and it would work with the full path from the csv file? Great that seems easy!

Will it avoid creating duplicates? Or do I have to do Subject-=Subject Subect+=Subject to achieve that?

Phil Harvey

The command will overwrite existing the Subject, so there shouldn't be duplicates unless they exist in your 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 ($).

mbuzina

Hmm, I just get No Writeable tags set from test.csv when I do this:
test.csv (snippet)
SourceFile,Subject
/volume1/photo/Urlaube/2021_06 Tennisreise Juist/IMG_6717.HEIC,"dreirad, einrad, fahrrad, massenverkehrsmittel, rad, transport, verkehrswesen, öffentliche verkehrsmittel, öffentlicher verkehr, bicycle, transportation, Juist Tennisreise Urlaub 2021_06, Tennisreise, Urlaub, Urlaub 2021, Urlaub mit Freunden"
/volume1/photo/Urlaube/2021_06 Tennisreise Juist/IMG_6714.HEIC,"dreirad, einrad, fahrrad, massenverkehrsmittel, rad, transport, verkehrswesen, öffentliche verkehrsmittel, öffentlicher verkehr, bicycle, transportation, Juist Tennisreise Urlaub 2021_06, Tennisreise, Urlaub, Urlaub 2021, Urlaub mit Freunden"
/volume1/photo/Urlaube/2021_06 Tennisreise Juist/IMG_6692.HEIC," essen und trinken, bier, drink, essen, getränk, lager, stout, beer, drink, food, Juist Tennisreise Urlaub 2021_06, Tennisreise, Urlaub, Urlaub 2021, Urlaub mit Freunden"


call:
exiftool -sep ", " -tagsFromFile test.csv .

Will try a bit more. Also tried relative path (did not work) and setting subject manually on a file (did work)

P.S.: I have seen the unquoted path with spaces - I tried relative as well, no spaces.

Phil Harvey

Use the -csv option, not -tagsfromfile

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