ExifTool Forum

ExifTool => Newbies => Topic started by: Rowan1002 on May 10, 2020, 07:04:35 AM

Title: Add Date Based on Sequence
Post by: Rowan1002 on May 10, 2020, 07:04:35 AM
Hi All - I have been struggling with this for a while.

I have a Mac, and have a folder which includes photos taken on my IPhone. I have used exiftool to rename in bulk all of the files so they are now in the correct order sequentially, which is great.

The issue I have is that, as some many of them were received on Whatsapp, when I upload them to "Photos" in my Mac, those Whatsapp pics end up in random dates.

Is there a way I can apply a command which will adjust the Create date of only those pictures without a create date and make it match the create date of either the photo before or after it in the sequence (as an estimated date)? The command would also need to not change the date if there is a create date already present, as I only want to redate the photos from Whatsapp...

Bit complex but hoping someone may have the solution? I think the main issue is that I want the command to use the previous or next photo's date as an estimate..not sure if possible.
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 10, 2020, 08:18:05 AM
Quote from: Rowan1002 on May 10, 2020, 07:04:35 AM
make it match the create date of either the photo before or after it in the sequence (as an estimated date)?

How do you determine the name of the photo before/after?  ie. what is the form of the file names?  If it is something like IMG_12345.jpg with a sequential number for each file, then this is possible, but will be a bit tricky.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 10, 2020, 09:03:06 AM
Hi Phil - thanks for coming back to me.

I batch name changed them to the format: IMG_00001.JPEG, IMG_00002.MOV, and so on.

I guess I can always batch name change them again if a different naming format will work better?

Thanks, R
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 10, 2020, 09:10:12 AM
Just to add, for example, if I drop the first 30 files into Mac "Photos" and the photos are all taken in Jan 2010 with one file received at some point in Jan 2010 via WhatsApp and that one happens to be IMG_000025 - in finder it will be in the right order but it will go into "Photos" on Mac at May 2019 (even though I don't see that date in it's EXIF properties. So ends up at the end of the sequence.

Hope that helps to explain.
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 10, 2020, 09:22:21 AM
Hi Rowan,

OK, you can do it like this, using 2 commands:

1. exiftool '-symlink<tmp/${filename;s/(\d+)/sprintf("%.5d",$1+1)/e}' DIR

2. exiftool -tagsfromfile tmp/%f.%e -createdate -if 'not $createdate' -fileorder filename DIR

The first command creates a set of symbolic links to the file with the previous number to be used when copying the CreateDate.

The trick is to use a symlink instead of a hard link and process the files in order of file name in the second command so that multiple consecutive missing CreateDates will be set properly.

After you are done with the command, you can delete the "tmp" directory containing the symlinks.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 11, 2020, 12:27:59 PM
Hi Phil,

Thanks so much - that seems to have worked!!!

Just for reference, sometimes the image has been dated to the file which is a couple of files back in the sequence (not sure why?), but in most cases it has dated to the date of the previous image in the sequence!

Couple of q's -

1. Out of curiosity - which date in the Exif Data would that have adjusted? (eg. I assume it's not 'modified' or 'created'?). Reason for the question is - now the files are named in sequential order and the Whatsapp images now have a date in the Exif data (which is great!) I want to include the date in the file name (see point 2 below).

2. To do this I used this command: exiftool -d '%Y%m%d-%H%M%%-03.c.%%e' '-filename<CreateDate' DIR, which has worked, the only files that didn't rename are .PNG files, they seem to be screenshots images. For these files, the file names didn't change and when you import them into 'Photos' on Mac they are the only images that end up still in a random date (7 Jul 2019, which I assume could be the last modified date) - any idea why these wouldn't have been picked up by the symlink command?

Thanks, Rowan
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 11, 2020, 01:20:06 PM
Hi Rowan,

Quote from: Rowan1002 on May 11, 2020, 12:27:59 PM
sometimes the image has been dated to the file which is a couple of files back in the sequence

Interesting, but I don't see how this could ever happen because the tag is copied only from the softlink with the same name (which is linked only to the file with the previous number).

Quote1. Out of curiosity - which date in the Exif Data would that have adjusted?

This will write the EXIF CreateDate tag for JPG files.  You could also write DateTimeOriginal and/or ModifyDate if you want.  To write all three, use AllDates instead.

Quoteany idea why these wouldn't have been picked up by the symlink command?

The symlink probably worked, but nothing will be copied for these files if CreateDate doesn't exist.  Use this command to see what date/time tags are available:

exiftool -time:all -a -G1 FILE

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 11, 2020, 08:51:49 PM
Hi Phil,

I have tried the command you mentioned to check the dates/time tags on a sample of the files and they do have dates (see below for some examples).

Does the below data indicate at all why these particular .PGN files did not rename to the dates even after I applied the symlink command that you suggested and the rename command I posted in my previous post?

Instead, as mentioned, when I drop these files into 'Photos' on Mac, they all go into 19 MAY 2017 which seems to be their created date (maybe this is the date that I downloaded them from Iphone to Mac). Not sure why this is, as after I use your symlink command they should have been re-dated to the previous file in the file sequence?

Last login: Mon May 11 19:28:58 on ttys000
Rowans-MBP:~ james$ exiftool -time:all -a -G1 /Users/james/Pictures/Exiftest\ -\ successful\ except\ for\ PGN/IMG_00176.PNG
[System]        File Modification Date/Time     : 2014:09:02 23:39:12+01:00
[System]        File Access Date/Time           : 2020:05:11 19:29:11+01:00
[System]        File Inode Change Date/Time     : 2020:05:11 17:10:42+01:00
Rowans-MBP:~ james$ exiftool -time:all -a -G1 /Users/james/Pictures/Exiftest\ -\ successful\ except\ for\ PGN/IMG_00236.PNG
[System]        File Modification Date/Time     : 2014:09:02 23:41:21+01:00
[System]        File Access Date/Time           : 2020:05:11 19:29:10+01:00
[System]        File Inode Change Date/Time     : 2020:05:11 17:10:42+01:00
Rowans-MBP:~ james$ exiftool -time:all -a -G1 /Users/james/Pictures/Exiftest\ -\ successful\ except\ for\ PGN/IMG_00254.PNG
[System]        File Modification Date/Time     : 2014:09:02 23:41:24+01:00
[System]        File Access Date/Time           : 2020:05:11 19:29:08+01:00
[System]        File Inode Change Date/Time     : 2020:05:11 17:10:42+01:00
Rowans-MBP:~ james$ exiftool -time:all -a -G1 /Users/james/Pictures/Exiftest\ -\ successful\ except\ for\ PGN/IMG_00273.PNG
[System]        File Modification Date/Time     : 2014:09:02 23:41:31+01:00
[System]        File Access Date/Time           : 2020:05:11 19:29:12+01:00
[System]        File Inode Change Date/Time     : 2020:05:11 17:10:42+01:00
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 11, 2020, 09:53:54 PM
The PNG files have do not have CreateDate tag, which is what you are copying to the FileName.  They have only FileModifyDate, FileAccessDate and FileInodeChangeDate (I should have asked you to add -s to the command so you could see the tag names, so this would be more clear).

Try changing CreateDate to FileModifyDate and adding -ext png to rename only the PNG files according to the FileModifyDate instead.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 12, 2020, 05:15:38 AM
Hi Phil,

Great - the PNG files did rename using the command.

1. The FileModifyDate however doesn't really represent their date taken as well as the order they were in the original naming sequence of IMG_00025 etc. So is there a way we can use that sequence to date them rather than their FileModifyDate?

2. When dropping them into Photos on Mac they still all end up in 17 JUL 2019?

The file name format is now like so: 20140902-234143-003.PNG

Thanks, Rowan
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 12, 2020, 07:31:49 AM
Are the PNG images numbered in the same sequence as JPG images.  ie)

IMG_00001.jpg
IMG_00002.jpg
IMG_00003.png
IMG_00004.jpg

?

If so, my scheme fails because the symlinks won't work if the extensions are different.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 12, 2020, 07:50:54 AM
Hi Phil,

Yes that is the exact format of my list, for completeness, the file list also includes some .MOV files which are probably video's taken on Iphone.

Got it re. your symlink not working with the extensions being different - is there another method I could use to give the png files the same date as the prior or post file in the sequence?

Thanks, R
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 12, 2020, 02:23:12 PM
OK.  This should work for files with different extensions (the symlink file is created without an extension):

1. exiftool '-symlink<tmp/${filename;s/(\d+)/sprintf("%.5d",$1+1)/e;s/\.\w+$//}' DIR

2. exiftool -tagsfromfile tmp/%f -createdate -if 'not $createdate' -fileorder filename DIR

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 12, 2020, 05:28:59 PM
Hi Phil,

Ok applied just the two commands on a smaller test folder & then dropped the files into Photos on Mac.

Doesn't seem to have worked for some reason?

See below, the first command had the below result:
1 directories scanned
    0 image files updated
  253 image files unchanged
    0 symbolic links created
  253 symbolic links could not be created

The second command had the below result:
  1 directories scanned
  167 files failed condition
    0 image files updated
   86 image files unchanged

Then dropped them into Photos on Mac to see the result. The order still doesn't match that of the file sequence, as I still I have a bulk of files which are in the 7JUL2019 date. It's a mixture of JPEG files and PNG files.

Maybe I need to change the commands?

Thanks, Rowan
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 12, 2020, 06:10:27 PM
The first command didn't create any symlinks.  It should have given some warnings to indicate why.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 12, 2020, 06:31:33 PM
Hi Phil,

The warnings are:

Warning: Error creating symbolic link 'tmp/IMG_00130' - /Users/james/Pictures/EXIFTEST/IP6a/IMG_00129.JPG

Not sure why it didn't work?

Just a thought, could it be that before I ran your commands I renamed the files into a sequence IMG_00001, rather than their existing file names and format of IMG_7775 which is not really sequential as there are missing files in the sequence - hence why I changed it before running your commands to  to a brand new sequence?

Would that cause an issue for your commands?

Thanks, R
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 12, 2020, 08:43:28 PM
Either the file exists, or you don't have permission to create the file.  Make sure you have write permission to create the "tmp" directory in the current directory when you are running ExifTool.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 12, 2020, 09:49:35 PM
Hi Phil,

Should be no issue with permissions as my laptop & pics. So what I did is downloaded the pictures fresh from my harddrive. Then started the commands fresh. This time I get the below.

Couple of things to note - I ran all of the commands in the below order one after another on the same folder. One of the commands created some new files tagged as "IMG_xxxx - original", I deleted these new files and then ran the next command. And I'm not sure I am following you on the 'tmp' thing (should one of the commands be creating a new 'tmp' directory somewhere, if so where? As not sure I am following that bit of your instructions.

1. Result for Command: exiftool '-symlink<tmp/${filename;s/(\d+)/sprintf("%.5d",$1+1)/e;s/\.\w+$//}' DIR

1 directories scanned
0 image files updated
1129 image files unchanged
120 symbolic links created
1009 symbolic links could not be created

2. Result for Command: exiftool -tagsfromfile tmp/%f -createdate -if 'not $createdate' -fileorder filename DIR

1 directories scanned
876 files failed condition
30 image files updated
223 image files unchanged

3. Result for Command: exiftool -d '%Y%m%d-%H%M%S%%-03.c.%%e' '-filename<CreateDate' /Users/james/Pictures/IP4\ redownladed\ pics\ numbered/IP4

1 directories scanned
906 image files updated
223 image files unchanged

The Warning is as follows for the unchanged files:

Warning: No writable tags set from /Users/james/Pictures/IP4 redownladed pics numbered/IP4/IMG_00656.JPG

Again it looks like the unchanged files are a mix of screenshots and whatsapp received images.  I dropped all photos into Mac Photos and the outcome is that a bunch of those unchanged files end up in 7Jul2019 and a bunch end up in today's date...

Any ideas what to do next?

Thanks, Rowan
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 13, 2020, 06:43:30 AM
Hi Rowan,

Quote from: Rowan1002 on May 12, 2020, 09:49:35 PM
And I'm not sure I am following you on the 'tmp' thing (should one of the commands be creating a new 'tmp' directory somewhere, if so where?

In the current directory.

Quote1009 symbolic links could not be created

Then the links already exist.

Quote2. Result for Command: exiftool -tagsfromfile tmp/%f -createdate -if 'not $createdate' -fileorder filename DIR

1 directories scanned
876 files failed condition
30 image files updated
223 image files unchanged

Then either there weren't symlink files for the unchanged files, or they are not sequentially numbered, or the first number in the sequence doesn't have a CreateDate.

Quote3. Result for Command: exiftool -d '%Y%m%d-%H%M%S%%-03.c.%%e' '-filename<CreateDate' /Users/james/Pictures/IP4\ redownladed\ pics\ numbered/IP4

1 directories scanned
906 image files updated
223 image files unchanged

Yes.  Those were the files for which the createDate wasn't written.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 13, 2020, 12:46:03 PM
Hi Phil,

Thanks for your ongoing support with this.

The files were all sequentially named so can't be that.

So that leaves only one of the other two reasons why they were unchanged I guess.

Any suggestions on how to proceed?

Thanks, Rowan
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 13, 2020, 07:46:11 PM
Hi Phil,

I ran the command below on the unchanged files, not sure if that helps but the result was below.

Command: exiftool -a -G1 -s -time:all

Result: Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all/Users/james/Pictures/IP4\ redownladed\ pics\ numbered/IP4/IMG_00723.JPG
Invalid TAG name: "time:all/Users/james/Pictures/IP4 redownladed pics numbered/IP4/IMG_00723.JPG"
No file specified

Not sure if this helps us to resolve this issue but thought I would try and get some more details.  The files were definitely sequentially ordered before I ran the commands.

Is there any way we can amend the command so that these files also get the date of the previous file in the sequence?

Thanks, Rowan
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 13, 2020, 09:45:06 PM
Quote from: Rowan1002 on May 13, 2020, 07:46:11 PM
Result: Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all/Users/james/Pictures/IP4\ redownladed\ pics\ numbered/IP4/IMG_00723.JPG
Invalid TAG name: "time:all/Users/james/Pictures/IP4 redownladed pics numbered/IP4/IMG_00723.JPG"
No file specified

You forgot a space after -time:all

I suggest you pay attention to the warnings that the commands are giving.  These should give you an indication of why the files aren't being updated.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 13, 2020, 10:07:13 PM
Hi Phil,

Ok so have taken another sample (just 42 files), and ran the two commands.

See below the warnings that come from the commands.

Last login: Thu May 14 02:51:18 on ttys000
Rowans-MBP:~ james$ exiftool '-symlink<tmp/${filename;s/(\d+)/sprintf("%.5d",$1+1)/e;s/\.\w+$//}' /Users/james/Downloads/EXIFTest
    1 directories scanned
    0 image files updated
   42 image files unchanged
   42 symbolic links created
Rowans-MBP:~ james$ exiftool -tagsfromfile tmp/%f -createdate -if 'not $createdate' -fileorder filename /Users/james/Downloads/EXIFTest
Warning: Error opening file - tmp/IMG_1704
Warning: Error opening file - tmp/IMG_1712
Warning: Error opening file - tmp/IMG_1713
Warning: Error opening file - tmp/IMG_1714
Warning: Error opening file - tmp/IMG_1715
Warning: Error opening file - tmp/IMG_1716
Warning: Error opening file - tmp/IMG_1717
Warning: Error opening file - tmp/IMG_1718
Warning: Error opening file - tmp/IMG_1719
Warning: Error opening file - tmp/IMG_1720
Warning: Error opening file - tmp/IMG_1722
Warning: Error opening file - tmp/IMG_1723
Warning: Error opening file - tmp/IMG_1724
Warning: Error opening file - tmp/IMG_1725
Warning: Error opening file - tmp/IMG_1747
Warning: Error opening file - tmp/IMG_1749
Warning: Error opening file - tmp/IMG_1751
Warning: Error opening file - tmp/IMG_1752
Warning: Error opening file - tmp/IMG_1753
    1 directories scanned
   23 files failed condition
    0 image files updated
   19 image files unchanged


An example of one of the files is:

Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Downloads/EXIFTest/IMG_1715.PNG
[System]        FileModifyDate                  : 2014:09:02 23:41:21+01:00
[System]        FileAccessDate                  : 2020:05:14 03:05:29+01:00
[System]        FileInodeChangeDate             : 2020:05:14 03:02:52+01:00
Rowans-MBP:~ james$

Do you know why it might not be working?

While the file does have a filemodifydate, its not accurate as the sequence of photos are from 2012, hence why I am trying to give it the date of the picture before it in the sequence. Again, when I drop this file into Mac Photos it comes up as 7 Jul 2019.

Do you think what I am trying to do is potentially not possible?

Thanks, Rowan
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 14, 2020, 06:31:41 AM
Hi Rowan,

Take this warning for example:

QuoteWarning: Error opening file - tmp/IMG_1712

That symlink should have been created for the file /Users/james/Downloads/EXIFTest/IMG_1711.JPG or .PNG.  Does the image file exist?  If not, then that is the problem.  But if it does, then our symlink command isn't doing what I expect if tmp/IMG_1712 is missing.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 14, 2020, 01:23:39 PM
Hi Phil,

Argh! You were right, before I ran the commands on that sample I forgot to rename the files to be in sequential order.

So today I got the same 42 files, renamed them into sequential order and tried the commands again.

Even stranger is that, even though these are the same 42 files as last time (taken fresh off harddrive), when you rename them into sequential order and run the commands, the Symlink doesn't work at all (see below).

No idea why that would be though....

Last login: Thu May 14 18:10:21 on ttys000
Rowans-MBP:~ james$ exiftool '-symlink<tmp/${filename;s/(\d+)/sprintf("%.5d",$1+1)/e;s/\.\w+$//}' /Users/james/Downloads/EXIFTestV2
Warning: Error creating symbolic link 'tmp/IMG_00043' - /Users/james/Downloads/EXIFTestV2/IMG_00042.JPG
Warning: Error creating symbolic link 'tmp/IMG_00042' - /Users/james/Downloads/EXIFTestV2/IMG_00041.JPG
Warning: Error creating symbolic link 'tmp/IMG_00041' - /Users/james/Downloads/EXIFTestV2/IMG_00040.PNG
Warning: Error creating symbolic link 'tmp/IMG_00028' - /Users/james/Downloads/EXIFTestV2/IMG_00027.PNG
Warning: Error creating symbolic link 'tmp/IMG_00034' - /Users/james/Downloads/EXIFTestV2/IMG_00033.JPG
Warning: Error creating symbolic link 'tmp/IMG_00033' - /Users/james/Downloads/EXIFTestV2/IMG_00032.JPG
Warning: Error creating symbolic link 'tmp/IMG_00027' - /Users/james/Downloads/EXIFTestV2/IMG_00026.PNG
Warning: Error creating symbolic link 'tmp/IMG_00025' - /Users/james/Downloads/EXIFTestV2/IMG_00024.PNG
Warning: Error creating symbolic link 'tmp/IMG_00031' - /Users/james/Downloads/EXIFTestV2/IMG_00030.PNG
Warning: Error creating symbolic link 'tmp/IMG_00019' - /Users/james/Downloads/EXIFTestV2/IMG_00018.JPG
Warning: Error creating symbolic link 'tmp/IMG_00020' - /Users/james/Downloads/EXIFTestV2/IMG_00019.PNG
Warning: Error creating symbolic link 'tmp/IMG_00032' - /Users/james/Downloads/EXIFTestV2/IMG_00031.PNG
Warning: Error creating symbolic link 'tmp/IMG_00026' - /Users/james/Downloads/EXIFTestV2/IMG_00025.PNG
Warning: Error creating symbolic link 'tmp/IMG_00022' - /Users/james/Downloads/EXIFTestV2/IMG_00021.PNG
Warning: Error creating symbolic link 'tmp/IMG_00010' - /Users/james/Downloads/EXIFTestV2/IMG_00009.JPG
Warning: Error creating symbolic link 'tmp/IMG_00036' - /Users/james/Downloads/EXIFTestV2/IMG_00035.JPG
Warning: Error creating symbolic link 'tmp/IMG_00035' - /Users/james/Downloads/EXIFTestV2/IMG_00034.JPG
Warning: Error creating symbolic link 'tmp/IMG_00009' - /Users/james/Downloads/EXIFTestV2/IMG_00008.JPG
Warning: Error creating symbolic link 'tmp/IMG_00021' - /Users/james/Downloads/EXIFTestV2/IMG_00020.PNG
Warning: Error creating symbolic link 'tmp/IMG_00023' - /Users/james/Downloads/EXIFTestV2/IMG_00022.PNG
Warning: Error creating symbolic link 'tmp/IMG_00037' - /Users/james/Downloads/EXIFTestV2/IMG_00036.JPG
Warning: Error creating symbolic link 'tmp/IMG_00024' - /Users/james/Downloads/EXIFTestV2/IMG_00023.PNG
Warning: Error creating symbolic link 'tmp/IMG_00038' - /Users/james/Downloads/EXIFTestV2/IMG_00037.PNG
Warning: Error creating symbolic link 'tmp/IMG_00007' - /Users/james/Downloads/EXIFTestV2/IMG_00006.JPG
Warning: Error creating symbolic link 'tmp/IMG_00013' - /Users/james/Downloads/EXIFTestV2/IMG_00012.JPG
Warning: Error creating symbolic link 'tmp/IMG_00014' - /Users/james/Downloads/EXIFTestV2/IMG_00013.JPG
Warning: Error creating symbolic link 'tmp/IMG_00008' - /Users/james/Downloads/EXIFTestV2/IMG_00007.JPG
Warning: Error creating symbolic link 'tmp/IMG_00040' - /Users/james/Downloads/EXIFTestV2/IMG_00039.PNG
Warning: Error creating symbolic link 'tmp/IMG_00012' - /Users/james/Downloads/EXIFTestV2/IMG_00011.JPG
Warning: Error creating symbolic link 'tmp/IMG_00006' - /Users/james/Downloads/EXIFTestV2/IMG_00005.JPG
Warning: Error creating symbolic link 'tmp/IMG_00005' - /Users/james/Downloads/EXIFTestV2/IMG_00004.JPG
Warning: Error creating symbolic link 'tmp/IMG_00011' - /Users/james/Downloads/EXIFTestV2/IMG_00010.JPG
Warning: Error creating symbolic link 'tmp/IMG_00039' - /Users/james/Downloads/EXIFTestV2/IMG_00038.PNG
Warning: Error creating symbolic link 'tmp/IMG_00029' - /Users/james/Downloads/EXIFTestV2/IMG_00028.PNG
Warning: Error creating symbolic link 'tmp/IMG_00015' - /Users/james/Downloads/EXIFTestV2/IMG_00014.JPG
Warning: Error creating symbolic link 'tmp/IMG_00002' - /Users/james/Downloads/EXIFTestV2/IMG_00001.JPG
Warning: Error creating symbolic link 'tmp/IMG_00016' - /Users/james/Downloads/EXIFTestV2/IMG_00015.PNG
Warning: Error creating symbolic link 'tmp/IMG_00030' - /Users/james/Downloads/EXIFTestV2/IMG_00029.PNG
Warning: Error creating symbolic link 'tmp/IMG_00004' - /Users/james/Downloads/EXIFTestV2/IMG_00003.JPG
Warning: Error creating symbolic link 'tmp/IMG_00018' - /Users/james/Downloads/EXIFTestV2/IMG_00017.JPG
Warning: Error creating symbolic link 'tmp/IMG_00017' - /Users/james/Downloads/EXIFTestV2/IMG_00016.JPG
Warning: Error creating symbolic link 'tmp/IMG_00003' - /Users/james/Downloads/EXIFTestV2/IMG_00002.JPG
    1 directories scanned
    0 image files updated
   42 image files unchanged
    0 symbolic links created
   42 symbolic links could not be created
Rowans-MBP:~ james$ exiftool -tagsfromfile tmp/%f -createdate -if 'not $createdate' -fileorder filename /Users/james/Downloads/EXIFTestV2
Warning: Error opening file - tmp/IMG_00015
Warning: Error opening file - tmp/IMG_00019
Warning: Error opening file - tmp/IMG_00020
Warning: Error opening file - tmp/IMG_00021
Warning: Error opening file - tmp/IMG_00022
Warning: Error opening file - tmp/IMG_00023
Warning: Error opening file - tmp/IMG_00024
Warning: Error opening file - tmp/IMG_00025
Warning: Error opening file - tmp/IMG_00026
Warning: Error opening file - tmp/IMG_00027
Warning: Error opening file - tmp/IMG_00028
Warning: Error opening file - tmp/IMG_00029
Warning: Error opening file - tmp/IMG_00030
Warning: Error opening file - tmp/IMG_00031
Warning: Error opening file - tmp/IMG_00036
Warning: Error opening file - tmp/IMG_00037
Warning: Error opening file - tmp/IMG_00038
Warning: Error opening file - tmp/IMG_00039
Warning: Error opening file - tmp/IMG_00040
    1 directories scanned
   23 files failed condition
    0 image files updated
   19 image files unchanged
Title: Re: Add Date Based on Sequence
Post by: StarGeek on May 14, 2020, 02:47:06 PM
Is tmp correct or shouldn't it be ./tmp?  I don't normally use linux type shells but I faintly remember having a problem like that in the past.
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 14, 2020, 06:54:36 PM
Hi StarGeek / Phil,

I think you're right!!! I replaced the tmp with /tmp and it seems to have worked!!!

So I ran the below 4 commands:

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

Command 3 - Rename Files

exiftool -d '%Y%m%d-%H%M%S%%-03.c.%%e' '-filename<CreateDate' DIR

Command 4

exiftool '-filemodifydate<createdate' DIR

Even though Screenshots get renamed to the correct date, in MAC Photos they end up in wrong date therefore Command 4 seems to correct this, as it seems Mac Photos uses filemodifydate to sort the pictures into dates.

Couple of Questions:

1. Once we replace the filemodifydate with createdate the files end up in Mac Photos in the correct date but should we add -p to prevent this getting messed up if the file is modified and the filemodifydate changes or would it not make a difference?

2. Is there any way to only make all of the above commands act only on the screenshot files and the files received by whatsapp (which include a mix of JPG and PNG files), and i.e. not make any changes to the files which were fine to start with (which were the ones actually taken on my Iphones)?
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 15, 2020, 09:03:17 AM
Quote from: Rowan1002 on May 14, 2020, 06:54:36 PM
1. Once we replace the filemodifydate with createdate the files end up in Mac Photos in the correct date but should we add -p to prevent this getting messed up if the file is modified and the filemodifydate changes or would it not make a difference?

You are setting the FileModifyDate at the last step, so adding -p to any of the command would have no effect.

Quote2. Is there any way to only make all of the above commands act only on the screenshot files and the files received by whatsapp (which include a mix of JPG and PNG files), and i.e. not make any changes to the files which were fine to start with (which were the ones actually taken on my Iphones)?

If you can identify these files by the metadata, then you can add a -if condition to all commands to avoid processing any files you want.

- Phil
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 15, 2020, 05:39:25 PM
Hi,

Ok will come back to the -IF potentially later.

So I ran the below two commands on a Directory of photos which includes many examples of the troublesome files (4 examples below), as you know the issue I have is with Screenshot images & images received in Whatsapp.

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

Tested Files (post commands)

File 1
Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Pictures/NEw/Iphone\ Photos/IMG_00485.JPG
[System]        FileModifyDate                  : 2020:05:15 22:26:11+01:00
[System]        FileAccessDate                  : 2020:05:15 22:28:11+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:28:10+01:00
[ExifIFD]       CreateDate                      : 2013:03:01 20:08:32

File 2
Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Pictures/NEw/Iphone\ Photos/IMG_00494.JPG
[System]        FileModifyDate                  : 2020:05:15 22:26:11+01:00
[System]        FileAccessDate                  : 2020:05:15 22:28:18+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:28:17+01:00
[ExifIFD]       CreateDate                      : 2013:03:20 15:15:36

File 3 (prior to CreateDate<FileModifyDate command mentioned below)
Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Pictures/NEw/Iphone\ Photos/IMG_01143.PNG
[System]        FileModifyDate                  : 2013:06:27 22:49:59+01:00
[System]        FileAccessDate                  : 2020:05:15 22:41:23+01:00
[System]        FileInodeChangeDate             : 2020:05:15 20:57:09+01:00

File 4
Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Pictures/NEw/Iphone\ Photos/IMG_00563.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:13+01:00
[System]        FileAccessDate                  : 2020:05:15 22:32:47+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:32:46+01:00
[PNG]           CreateDate                      : 2013:06:16 13:00:29

Result Analysis

File 1 & File 2: The first two files end up in MAC Photos correctly and they were Whatsapp files which have now been given CreateDate based on the previous file in the wider sequence of files. Mac used CreateDate to sort these two (which inconsistent with the 4th file I tested, see below, which used FileModifyDate).

File 3: Was also received on Whatsapp, however even after running the commands on the entire DIR, this one ends up with no Createdate, and then goes into Mac on date 7Jul19, which I don't understand because Mac Photos seems to use FileModifyDate in absence of Createdate to sort the pics, so surely it should end up in date 2013:06:27 22:49:59+01:00, instead it ends up in 7 JUL 2019.

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. This shouldn't be an issue if Mac Photos is using CreateDate to sort photos which test on File 1 & File 2 shows, however when I drop this file into Mac it sorts it by FileModifyDate, i.e. today's date!?

Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Pictures/NEw/Iphone\ Photos/IMG_01143.PNG
[System]        FileModifyDate                  : 2013:06:27 22:49:59+01:00
[System]        FileAccessDate                  : 2020:05:15 22:41:23+01:00
[System]        FileInodeChangeDate             : 2020:05:15 20:57:09+01:00
Rowans-MBP:~ james$ exiftool -if 'not $createdate' '-createdate<filemodifydate' /Users/james/Pictures/NEw/Iphone\ Photos/IMG_01143.PNG
    1 image files updated
Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Pictures/NEw/Iphone\ Photos/IMG_01143.PNG
[System]        FileModifyDate                  : 2020:05:15 22:54:38+01:00
[System]        FileAccessDate                  : 2020:05:15 22:54:43+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:54:38+01:00
[PNG]           CreateDate                      : 2013:06:27 22:49:59+01:00

File 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.

Any idea how I correct for these two files ? I have no idea about the third one? Is the fourth one using FileModifyDate to sort rather than CreateDate because it is a PNG file or something? Do I need a command that says -IF PGN file replace FileModifyDate with CreateDate?

Kinda lost now on how to fix all this.....

Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 15, 2020, 08:01:55 PM
Still trying to solve this! See below, in Mac Photos all of these files go in and sort by CreateDate, apart from the PNG file which goes in todays date...even though it's CreateDate is there and correct...I guess this proves PNG files sort by FileModifyDate even if there is a CreateDate present, while the rest of the files sort by CreateDate..

Update: Since running the below I changed the FileModifyDate to the same as the CreateDate using below command and now the file is sorting correctly.

exiftool '-filemodifydate<createdate'

So now I think that I need:

(1) to find some sort of command for the directory that will correct this for the rest of the directory, I'm thinking something like below??
exiftool -if '$filetype eq "PNG"' '-filemodifydate<createdate'

(2) to add something in the command that means the FileModifyDate doesn't change...

Last login: Sat May 16 00:19:29 on ttys000
Rowans-MBP:~ james$ exiftool -a -G1 -s -time:all /Users/james/Pictures/NEw/Iphone\ Photos/IMG_02335.JPG /Users/james/Pictures/NEw/Iphone\ Photos/IMG_02336.JPG /Users/james/Pictures/NEw/Iphone\ Photos/IMG_02337.JPG /Users/james/Pictures/NEw/Iphone\ Photos/IMG_02338.JPG /Users/james/Pictures/NEw/Iphone\ Photos/IMG_02339.JPG /Users/james/Pictures/NEw/Iphone\ Photos/IMG_02340.PNG /Users/james/Pictures/NEw/Iphone\ Photos/IMG_02341.JPG
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_02335.JPG
[System]        FileModifyDate                  : 2020:05:15 22:26:38+01:00
[System]        FileAccessDate                  : 2020:05:16 00:42:31+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:38+01:00
[ExifIFD]       CreateDate                      : 2014:10:25 01:30:05
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_02336.JPG
[System]        FileModifyDate                  : 2020:05:15 22:26:38+01:00
[System]        FileAccessDate                  : 2020:05:16 00:42:31+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:38+01:00
[ExifIFD]       CreateDate                      : 2014:10:25 01:30:05
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_02337.JPG
[System]        FileModifyDate                  : 2020:05:15 22:26:38+01:00
[System]        FileAccessDate                  : 2020:05:16 00:42:30+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:38+01:00
[ExifIFD]       CreateDate                      : 2014:10:25 01:30:05
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_02338.JPG
[System]        FileModifyDate                  : 2020:05:15 22:26:38+01:00
[System]        FileAccessDate                  : 2020:05:16 00:42:38+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:38+01:00
[ExifIFD]       CreateDate                      : 2014:10:25 01:30:05
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_02339.JPG
[System]        FileModifyDate                  : 2020:05:15 22:26:38+01:00
[System]        FileAccessDate                  : 2020:05:16 00:42:38+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:38+01:00
[ExifIFD]       CreateDate                      : 2014:10:25 01:30:05
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_02340.PNG
[System]        FileModifyDate                  : 2020:05:15 22:26:38+01:00
[System]        FileAccessDate                  : 2020:05:16 00:42:33+01:00
[System]        FileInodeChangeDate             : 2020:05:15 22:26:38+01:00
[PNG]           CreateDate                      : 2014:10:25 01:30:05
======== /Users/james/Pictures/NEw/Iphone Photos/IMG_02341.JPG
[System]        FileModifyDate                  : 2014:10:26 15:33:59+00:00
[System]        FileAccessDate                  : 2020:05:16 00:42:33+01:00
[System]        FileInodeChangeDate             : 2020:05:15 20:58:05+01:00
[IFD0]          ModifyDate                      : 2014:10:26 15:33:59
[ExifIFD]       DateTimeOriginal                : 2014:10:26 15:33:59
[ExifIFD]       CreateDate                      : 2014:10:26 15:33:59
[ExifIFD]       SubSecTimeOriginal              : 202
[ExifIFD]       SubSecTimeDigitized             : 202
[Composite]     SubSecCreateDate                : 2014:10:26 15:33:59.202
[Composite]     SubSecDateTimeOriginal          : 2014:10:26 15:33:59.202
    7 image files read
Rowans-MBP:~ james$
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 15, 2020, 08:56:40 PM
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
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 15, 2020, 09:27:26 PM
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
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 15, 2020, 09:29:59 PM
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
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 15, 2020, 10:35:47 PM
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


Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 16, 2020, 07:12:10 AM
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
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 16, 2020, 08:47:28 AM
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
Title: Re: Add Date Based on Sequence
Post by: Phil Harvey on May 17, 2020, 09:00:33 PM
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
Title: Re: Add Date Based on Sequence
Post by: Rowan1002 on May 22, 2020, 06:01:53 AM
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