Conditional tag copying if filename and date created alighn

Started by SkiesMK, February 29, 2024, 03:59:51 PM

Previous topic - Next topic

SkiesMK

I had previously transferred all of my iPhone photos to my laptop (Win10) to back them up. I now have a server running which I am looking to store these photos to. However, the photos were taken as LivePhotos so they were split into JPEG and MOV files. Each pair share the same name and date created.

The software I am using on the NAS will group these photos together provided their ContentIdnetifier tags are the same and they must have gotten mangled when transferring because they are all different.

I know that I can copy the ContentIdentifier individually using
exiftool -tagsfromfile src.jpg -ContentIdentifier dest.movand have tested that is what I want it to do.
However, I have thousands of photos this would need to be done for. is there a way that I could use a conditional in a directory to perform this action for all photo/video pairs? I wanted to check for both filename and date created as some of the numbering seems to cycle after 10,000 photos. All photos/videos are in the same directory as well

Phil Harvey

Comparing the date created will require using something advanced like the -fileNUM option.  However, I'm thinking we could run into more complications if the date strings aren't exactly the same between the JPG and MOV files.  Could you run this command on a pair to see what we are dealing with?:

exiftool -time:all -G1 -a FILE.jpg FILE.mov

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

SkiesMK

Here's the output I get when running that with two of the files.
======== IMG_1095.jpg
[System]        File Modification Date/Time     : 2024:02:29 12:41:47-06:00
[System]        File Access Date/Time           : 2024:02:29 15:12:48-06:00
[System]        File Creation Date/Time         : 2024:02:29 11:18:21-06:00
[IFD0]          Modify Date                     : 2023:06:11 16:48:50
[ExifIFD]       Date/Time Original              : 2023:06:03 20:18:55
[ExifIFD]       Create Date                     : 2023:06:03 20:18:55
[ExifIFD]       Offset Time                     : -05:00
[ExifIFD]       Offset Time Original            : -05:00
[ExifIFD]       Offset Time Digitized           : -05:00
[ExifIFD]       Sub Sec Time Original           : 168
[ExifIFD]       Sub Sec Time Digitized          : 168
[XMP-xmp]       Create Date                     : 2023:06:03 20:18:55
[XMP-xmp]       Modify Date                     : 2023:06:03 20:18:55
[XMP-photoshop] Date Created                    : 2023:06:03 20:18:55
[ICC-header]    Profile Date Time               : 2022:01:01 00:00:00
[Composite]     Create Date                     : 2023:06:03 20:18:55.168-05:00
[Composite]     Date/Time Original              : 2023:06:03 20:18:55.168-05:00
[Composite]     Modify Date                     : 2023:06:11 16:48:50-05:00
======== IMG_1095.MOV
[System]        File Modification Date/Time     : 2024:02:29 11:19:54-06:00
[System]        File Access Date/Time           : 2024:02:29 15:12:48-06:00
[System]        File Creation Date/Time         : 2024:02:29 11:18:21-06:00
[QuickTime]     Create Date                     : 2023:06:04 01:18:58
[QuickTime]     Modify Date                     : 2023:06:04 01:18:58
[Track1]        Track Create Date               : 2023:06:04 01:18:58
[Track1]        Track Modify Date               : 2023:06:04 01:18:58
[Track1]        Media Create Date               : 2023:06:04 01:18:58
[Track1]        Media Modify Date               : 2023:06:04 01:18:58
[Track2]        Track Create Date               : 2023:06:04 01:18:58
[Track2]        Track Modify Date               : 2023:06:04 01:18:58
[Track2]        Media Create Date               : 2023:06:04 01:18:58
[Track2]        Media Modify Date               : 2023:06:04 01:18:58
[Track3]        Track Create Date               : 2023:06:04 01:18:58
[Track3]        Track Modify Date               : 2023:06:04 01:18:58
[Track3]        Media Create Date               : 2023:06:04 01:18:58
[Track3]        Media Modify Date               : 2023:06:04 01:18:58
[Track4]        Track Create Date               : 2023:06:04 01:18:58
[Track4]        Track Modify Date               : 2023:06:04 01:18:58
[Track4]        Media Create Date               : 2023:06:04 01:18:58
[Track4]        Media Modify Date               : 2023:06:04 01:18:58
[Track5]        Track Create Date               : 2023:06:04 01:18:58
[Track5]        Track Modify Date               : 2023:06:04 01:18:58
[Track5]        Media Create Date               : 2023:06:04 01:18:58
[Track5]        Media Modify Date               : 2023:06:04 01:18:58
[Keys]          Creation Date                   : 2023:06:03 20:18:54-05:00

Looking at those timestamps, you are probably right that this may not be the best way to filter them. I did manually go through the files and try my best to filter out ones with repeated names, but I was hoping to use this as a fail-safe. Can the creation date be "fuzzied" to use up to the day rather than time? Else, is there another tag that would be better to use for this purpose?

SkiesMK

Ok, so I did find another forum post describing a similar process I was looking for here. It of course does not check the date created or anything, but I am thinking I may make a backup of my photos and attempt to use it on a group of them to see how it does. The more I look at it, the less concerned I am with it finding a JPEG and MOV with different date stamps/content, but I might just go through my library again to try to spot some of these now.

I went through looking for some other metadata that I would be able to try to use other than the date, but I'm not seeing anything that would match.

Phil Harvey

OK, I think this should work:

exiftool -file1 %d%f.JPG "-contentidentifier<file1:contentidentifier" -if "abs($file1:exif:createdate - $quicktime:createdate) < 3600" -api quicktimeutc -d %s -ext mov DIR

This will copy ContentIdentifier from the JPG to the corresponding MOV if the times are within 1 hour (3600 seconds), comparing the EXIF:CreateDate from the JPG with the QuickTime:CreateDate from the MOV (corrected to local time by the -api quicktimeutc option).  The -d %s option converts the date/time values to seconds since 1970 for easier comparing.

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

SkiesMK

Hey Phil,

Is there a way to see what a condition is evaluating to? The condition is always failing even when I extend the limit or set it >0. I checked the tags for both files to confirm they were similar (only a couple seconds differ from each other) so I wonder if it is not evaluating how I expected. Thanks.

StarGeek

Are you using PowerShell or CMD or are you running this on the NAS?

The above command should work in CMD. If you're running it on the NAS, swap the double/single quotes.

PS has different quoting rules, so you might try swapping the quotes, but no guarantee.
"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

SkiesMK

I am using PS on my Win10 laptop. I was using the above noted tags but saw that the creation times were about 4 hours apart. I then switched to using two tags that aligned closer in time as seen below, but could not get it to pass the condition. This was tried with both single and double quotes. (No I did not leave it as DIR when executing)

(base) PS > exiftool -exif:createdate IMG_1054.jpg                                                                                                                                                            Create Date                     : 2023:06:03 20:16:27
(base) PS > exiftool -keys:creationdate IMG_1054.mov                                                                                                                                                          Creation Date                   : 2023:06:03 20:16:27-05:00
(base) > exiftool -file1 %d%f.JPG "-contentidentifier<file1:contentidentifier" -if "abs($file1:exif:createdate - $keys:creationdate) <=360000" -api quicktimeutc -d %s -ext mov DIR
    1 directories scanned
    2 files failed condition
    0 image files read

Any thoughts on what would still be causing the conditional to fail? My directory contains 4 files (2 JPG and 2 MOV)

StarGeek

"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

SkiesMK

That looks to have done the trick. Thank you both for the help! I'll stick to using CMD for future endeavors with exiftool.