Batch Processing of many manual dates

Started by dRuEFFECT, November 17, 2024, 04:56:34 AM

Previous topic - Next topic

dRuEFFECT

I have a large catalog of photos that contain duplicates, many of which have different dates. Ultimately I want to dedupe photos and have the remaining photos to have the earliest date value from within the set of duplicates. I'm using Immich to identify duplicates and query the Immich API to give me duplicateId, filename, and dates. I take the least value of all dates related to an image, and then min value of this across all photos within the set of duplicates based on duplicateId.

I now want to take these externally calculated date values and bulk update the images using exiftool, and afterwards will proceed with removing duplicates within Immich.

I can run a series of updates like below, but for thousands of items this performs poorly as per  Common Mistake #3.

./exiftool -AllDates="2013:03:17 18:27:16" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130317_142716.IMG_0018.jpg"
./exiftool -AllDates="2013:03:17 18:27:16" "/mnt/user/media/Photos/Immich/library/dupes/2015/20151111_122348.012c8fcb632fc2ae910b3f9f85bdbc8b324ac8779d.jpg"
./exiftool -AllDates="2013:05:17 18:25:19" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130517_142519.2013-05-17 14.25.19.jpg"
./exiftool -AllDates="2013:05:17 18:25:19" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130517_142519.IMG_0236.jpg"
./exiftool -AllDates="2013:05:17 18:25:19" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130517_142519.IMG_1193+1.JPG"
./exiftool -AllDates="2013:05:17 18:25:19" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130517_142519.011efbe82ea3f14bd43d76eb3d28cb2a746afdd5bb.jpg"
./exiftool -AllDates="2015:10:08 23:02:36" "/mnt/user/media/Photos/Immich/library/dupes/2015/20151008_190236.IMG_7384.JPG"
./exiftool -AllDates="2015:10:08 23:02:36" "/mnt/user/media/Photos/Immich/library/dupes/2015/20151009_020816.IMG_7386.JPG"
./exiftool -AllDates="2013:01:28 00:28:06" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130127_192806.01bbaaca6009efdc5db9667a09460791d081ef5f0d.jpg"
./exiftool -AllDates="2013:01:28 00:28:06" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130127_192806.IMG_0170.jpg"
./exiftool -AllDates="2012:11:10 06:27:29" "/mnt/user/media/Photos/Immich/library/dupes/2012/20121110_012729.IMG_0062.jpg"
./exiftool -AllDates="2012:11:10 06:27:29" "/mnt/user/media/Photos/Immich/library/dupes/2012/20121110_012729.IMG_0083.jpg"
./exiftool -AllDates="2012:11:10 06:27:29" "/mnt/user/media/Photos/Immich/library/dupes/2012/20121110_012729.0113dd40393ad07556bb7349eef5d60a7601495893.jpg"
./exiftool -AllDates="2014:01:01 06:16:34" "/mnt/user/media/Photos/Immich/library/dupes/2014/20140101_011634.01ee3fe0587b77578d951963118f8e2a58f8b7b52e.jpg"
./exiftool -AllDates="2014:01:01 06:16:34" "/mnt/user/media/Photos/Immich/library/dupes/2014/20140101_011634.IMG_0311.jpg"
./exiftool -AllDates="2013:09:12 00:24:07" "/mnt/user/media/Photos/Immich/library/dupes/2013/20130911_202407.IMG_3085.JPG"

So question is, how can I pass these filename and datetime values in from a file into a single exiftool command?

StarGeek

I would suggest reformatting the data into a CSV file. The result should look like this
SourceFile,AllDates
/mnt/user/media/Photos/Immich/library/dupes/2013/20130317_142716.IMG_0018.jpg,2013:03:17 18:27:16
/mnt/user/media/Photos/Immich/library/dupes/2015/20151111_122348.012c8fcb632fc2ae910b3f9f85bdbc8b324ac8779d.jpg,2013:03:17 18:27:16

And then you could use this command with the -csv option
exiftool -r -csv=file.csv /mnt/user/media/Photos/Immich/library/dupes

You don't mention your OS, but if you are on Mac/Linux, you could use sed to reformat the data. ChatGPT gave me this command, which should be tested to make sure ChatGPT wasn't drunk when writing it
sed 's|^\.\/exiftool -AllDates="\(.*\)" "\(.*\)"|\2,\1|' commands.txt >file.csv

If you're on Windows, you can get sed (and other useful Linux commands) from MSys2. Otherwise you would have to work up a script of some sort.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

dRuEFFECT

thanks, I'm running this now but it seems to be taking a while as it's running through ALL files in the directory and comparing the filename to the SourceFile list in the csv... is there another way so that exiftool directly targets the files in the list rather than scanning through the whole library?

StarGeek

Quote from: dRuEFFECT on November 18, 2024, 02:31:14 PMis there another way so that exiftool directly targets the files in the list rather than scanning through the whole library?

The csv file is a look up table and not what exiftool uses to select the files to process.

You could copy the SourceFile column into a text file, remove the "SourceFile" line, and use the -@ option.

Example of how the text file would look
/mnt/user/media/Photos/Immich/library/dupes/2013/20130317_142716.IMG_0018.jpg
/mnt/user/media/Photos/Immich/library/dupes/2015/20151111_122348.012c8fcb632fc2ae910b3f9f85bdbc8b324ac8779d.jpg

And the command would change to
exiftool -r -csv=file.csv -@ filelist.txt
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

dRuEFFECT

This worked great! Thank you so much!