Add Date Based on Sequence

Started by Rowan1002, May 10, 2020, 07:04:35 AM

Previous topic - Next topic

Rowan1002

Also, see below - these are a bunch of screenshots sandwiched between two photo's taken on Iphone. All in sequential order, so we would have expected the Symlink to assign the screenshots with the date of the first file i.e. all files should be dated in May 2012. We can see here that the Screenshots are dated Jul 2012 which means that the Photo's somehow Symlinked to something else.

Phil, how can this be? I thought we built the command to work based on sequence of files, again is this a quirk due to the files being PNG files?

======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00277.JPG
[System]        FileModifyDate                  : 2014:09:02 23:41:20+01:00
[System]        FileAccessDate                  : 2020:05:16 01:49:48+01:00
[System]        FileInodeChangeDate             : 2020:05:15 20:56:13+01:00
[IFD0]          ModifyDate                      : 2012:05:26 20:39:38
[ExifIFD]       DateTimeOriginal                : 2012:05:26 20:39:38
[ExifIFD]       CreateDate                      : 2012:05:26 20:39:38
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00278.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:01+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:09+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:01+01:00
[PNG]           CreateDate                      : 2012:07:09 18:16:58
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00279.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:02+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:02+01:00
[PNG]           CreateDate                      : 2012:07:09 18:16:58
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00280.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:02+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:02+01:00
[PNG]           CreateDate                      : 2012:07:16 14:43:09
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00281.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:02+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:02+01:00
[PNG]           CreateDate                      : 2012:07:16 14:43:09
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00282.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:02+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:02+01:00
[PNG]           CreateDate                      : 2012:07:20 12:11:34
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00283.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:02+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:02+01:00
[PNG]           CreateDate                      : 2012:07:20 15:19:11
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00284.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:03+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:03+01:00
[PNG]           CreateDate                      : 2012:07:20 16:20:07
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00285.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:03+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:03+01:00
[PNG]           CreateDate                      : 2012:07:20 20:58:04
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00286.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:03+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:03+01:00
[PNG]           CreateDate                      : 2012:07:20 20:58:07
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00287.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:03+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:03+01:00
[PNG]           CreateDate                      : 2012:07:21 20:50:36
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00288.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:03+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:03+01:00
[PNG]           CreateDate                      : 2012:07:21 20:50:41
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00289.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:04+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:04+01:00
[PNG]           CreateDate                      : 2012:07:21 20:50:43
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00290.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:04+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:04+01:00
[PNG]           CreateDate                      : 2012:07:21 20:51:41
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00291.JPG
[System]        FileModifyDate                  : 2014:09:02 23:41:23+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 20:56:14+01:00
[IFD0]          ModifyDate                      : 2012:05:31 14:25:06
[ExifIFD]       DateTimeOriginal                : 2012:05:31 14:25:06
[ExifIFD]       CreateDate                      : 2012:05:31 14:25:06
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_00292.JPG
[System]        FileModifyDate                  : 2014:09:02 23:41:23+01:00
[System]        FileAccessDate                  : 2020:05:16 01:50:17+01:00
[System]        FileInodeChangeDate             : 2020:05:15 20:56:14+01:00
[IFD0]          ModifyDate                      : 2012:05:31 18:50:01
[ExifIFD]       DateTimeOriginal                : 2012:05:31 18:50:01
[ExifIFD]       CreateDate                      : 2012:05:31 18:50:01
   16 image files read

Phil Harvey

Quote from: Rowan1002 on May 15, 2020, 05:39:25 PM
So then I ran:

exiftool -if 'not $createdate' '-createdate<filemodifydate' /Users/james/Pictures/NEw/Iphone\ Photos/IMG_01143.PNG

Result was below which has given the file the CreateDate but changed the FileModifyDate to todays date.

Ah, right.  This is what you were talking about.  Yes.  Add the -P (capital "P") option to this command to avoid resetting the FileModifyDate when the file is written.

QuoteFile 4: The last image is a screenshot. Even though it was subjected to the same commands, the screenshot ends up in Mac Photos based on the filemodifydate, and not createdate as per the other files.

Historically, software hasn't had very good support for PNG metadata.  But I can't speak for the current situation of Mac Photos.

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

Phil Harvey

Quote from: Rowan1002 on May 15, 2020, 08:56:40 PM
We can see here that the Screenshots are dated Jul 2012 which means that the Photo's somehow Symlinked to something else.

I can't see that because:

1. I don't know the situation before you ran the command.

2. I can't see the symlinks (do a "ls -l tmp" to see them)

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

Rowan1002

#33
Hi Phil,

Ok yes makes sense, of course you would need to see that information before we can determine what is happening with the symlink.

I ran the "ls -l tmp" command to check the symlinks. It brought back thousands of entries, basically every symlink I have tried over the last 2 weeks while trying to solve this. See below, I picked out the file IMG_00278.PNG as an example. Also, at the bottom of this post I have included the file info that existed before the commands were applied which we can use as a comparison.

The below are the entries that I see, but the directories that we see are all test folders which I deleted a few days ago.

Today I had run the symlink command on the following directory which I cannot see below: Rowans-MBP:~ james$ /Users/james/Pictures/NEw/Iphone\ Photos.

Does this indicate that the symlink didn't work? If so, I do not understand how those images end up with create date of July 2012? The only two commands I applied were:

Command 1 - Symlink: exiftool '-symlink</tmp/${filename;s/(\d+)/sprintf("%.5d",$1+1)/e;s/\.\w+$//}' DIR
Command 2: exiftool -tagsfromfile /tmp/%f -createdate -if 'not $createdate' -fileorder filename -overwrite_original DIR


Symlink:

lrwxr-xr-x  1 james  staff  58 12 May 20:55 IMG_00278 -> /Users/james/Pictures/EXIFTEST/IP4SecondTest/IMG_00277.PNG
lrwxr-xr-x  1 james  staff  81 11 May 20:27 IMG_00278.JPG -> /Users/james/Pictures/Exiftest - successful except for PGN/IP4sTest/IMG_00277.JPG
lrwxr-xr-x  1 james  staff  53 11 May 16:22 IMG_00278.PNG -> /Users/james/Pictures/Iphone Photos/IP4/IMG_00277.PNG

Original File Data (before running Symlink)

======== /Users/james/Pictures/Original Data/IMG_00277.JPG
[System]        FileModifyDate                  : 2014:09:02 23:41:20+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
[IFD0]          ModifyDate                      : 2012:05:26 20:39:38
[ExifIFD]       DateTimeOriginal                : 2012:05:26 20:39:38
[ExifIFD]       CreateDate                      : 2012:05:26 20:39:38
======== /Users/james/Pictures/Original Data/IMG_00278.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:21+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00279.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:21+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00280.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:21+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00281.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:21+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00282.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:21+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00283.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:21+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00284.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:22+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:34+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00285.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:22+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:35+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00286.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:22+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:35+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00287.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:22+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:35+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00288.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:22+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:35+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00289.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:22+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:35+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00
======== /Users/james/Pictures/Original Data/IMG_00290.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:23+01:00
[System]        FileAccessDate                  : 2020:05:16 03:27:35+01:00
[System]        FileInodeChangeDate             : 2020:05:16 03:27:33+01:00



Phil Harvey

It sounds to me like all of your old symlinks are creating problems because you have since moved the original files.

You should delete the entire directory containing the symlinks to start fresh before you run the first command.

Also, don't delete the "_original" files because they are backups of the originals.  After you run the commands again, if it doesn't behave as expected for a specific file, check to see where the symlink for that file points, then check the linked file to see what the CreateDate was.  Then check the _original file to see if it already had an incorrect CreateDate (because one pre-existing incorrect CreateDate could cause lots of confusion as well).

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

Rowan1002

#35
Hi Phil,

Odd because those directories don't exist anymore so funny how the "ls -l tmp" command shows all of those links. Maybe it shows a record of all links created, even if they have now been deleted?

Or maybe the link exists even after directories are deleted? In the below you can see that only the bottom directory is a directory and exists, and that's the one I'm using....the others do not exists yet come up in the "ls -l tmp" extract...

Last login: Sat May 16 13:29:32 on console
Rowans-MBP:~ james$ /Users/james/Pictures/Exiftest - successful except for PGN/IP4sTest
-bash: /Users/james/Pictures/Exiftest: No such file or directory
Rowans-MBP:~ james$ /Users/james/Pictures/Iphone Photos/IP4
-bash: /Users/james/Pictures/Iphone: No such file or directory
Rowans-MBP:~ james$ /Users/james/Pictures/NEw
-bash: /Users/james/Pictures/NEw: is a directory

Phil Harvey

Quote from: Rowan1002 on May 16, 2020, 08:47:28 AM
Odd because those directories don't exist anymore so funny how the "ls -l tmp" command shows all of those links.

A symbolic link may point to a non-existent 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 ($).

Rowan1002

Hi Phil & everyone!

To confirm - deleting all folders and files, then redownloading the pictures from hard drive to Mac, and then running the commands has solved it. Seems like even though I had deleted folders, symlinks were still existing, so I deleted all the folders from that directory including the source pictures, and as mentioned redownloaded them, and ran the commands.

Files are now in Mac photo's sorted by date, with the Whatsapp and Screenshot pictures having either been given the date of the previous file (via the symlink), and the PGN files then given a create date equal to the file modify date (and the file modify date then being fixed with the -P).

All worked, and pictures correctly sorted in Mac Photos!

Thanks for all the support / advice on this topic!

Thanks, Rowan