Main Menu

Modified to Created

Started by findlay70, January 10, 2017, 08:57:46 AM

Previous topic - Next topic

findlay70

Hello,
As a forewarning, I'm not a programmer, so installing ExifTool on my Mac and getting it up and running was a huge success. So I'm looking for some help, please, with a basic command.
I backed up my photos over the years and for some [unknown] reason, in the copy/backup process the "Created" date was updated to the date when the file was copied. So now I have a batch of photos where the create date is incorrect and when adding the to Photos on my new Mac, they are all over the place. Fortunately, I did this with a few hundred (and not the 30,000 images), so I have a chance to correct these still before I have a mess on my hands.
Looking at all the files, the Modified date is the date at which the images were taken , so I'd like to copy the Modified Date to the Create Date.
If someone can provide the script to do this, it will be greatly appreciated.
Thanks in advance
Andy

Phil Harvey

Hi Andy,

I assume you are talking about the filesystem creation date for the file?  (The one shown as "Created:" when you select File/Info in the Finder?)  ExifTool calls this FileCreateDate.

Unfortunately ExifTool can not access the FileCreateDate on Mac systems.  However, you may be able to set this indirectly, but first I need to be sure we are talking about the same thing.  Can you show me the output of this command on one of your files?:

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

(drag and drop the file onto the Terminal window instead of typing "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 ($).

findlay70

Dear Phil,
Thanks for the fast feedback and support.
Yes, this is the creation date for the file - it is also shown below the file (photo) in the finder.
The output of the command is :
[System]        FileModifyDate                  : 2014:02:18 16:01:30-07:00
[System]        FileAccessDate                  : 2017:01:10 12:21:33-07:00
[System]        FileInodeChangeDate             : 2017:01:10 12:13:46-07:00
[ICC-header]    ProfileDateTime                 : 1999:06:03 00:00:00
[XMP-xmp]       MetadataDate                    : 2014:02:18 23:42:07+02:00
I do have a hard drive and I can put these files onto a windows drive.
Thanks again.
Andy

Hayo Baan

What type of files are we talking about?
File system dates are the worst place to put e.g. the create date in, simply because they are altered whenever you do something with the file (including copying). It is better to rely on metadata inside the file, e.g. DataTimeOriginal.

Further note that File System Create Date is NOT what is shown by Phil's command, what is show is the File Inode Change Date which is simply the time when the file directory entry got changed (e.g. after a copy, a permission change, etc.). I you want to see the actual File Create Date you'll have to explicitly ask for it using -MDItemFSCreationDate (or use the command stat -f '%SB %N' FILES).

Note: because the modify date is in the past, I am actually quite certain the File Creation date is set to that date too (you can not modify something that doesn't exist yet ;)). So to be honest I think your problem is different.

Regardless, as I said, I think you'd better save the date you want your photos to have to one to the metadata tags most appropriate for that purpose. Which tag that is depends on the type of files in question.
Hayo Baan – Photography
Web: www.hayobaan.nl

findlay70

Thanks for your response Hayo.
The files are simple JPEG. I checked the METADATA and the DataTimeOriginal or capture time doesn't exist... This will probably burn your ears, but I take images with Point and Shoot cameras - all JPEG.
I agree with you and would love to have all the DataTimeOriginal stamps, but unfortunately they dont exist...
Thanks
Andy

Hayo Baan

Hi Andy, no problem shooting JPEG with point and shoots! Actually makes it easier to fix your problem since they're all one format.

What makes me wonder though is that they do not have the DateTimeOriginal tag. Are you sure these are the files that are originally from your cameras? Or have they been edited (if so, what photo editor did you use)?

Anyway, setting the datetime original to the file modification time is easy: exiftool '-DateTimeOriginal<FileModifyDate' FILEorDIR
Try this on a couple of files and verify they indeed show up how you like them in Photos.

If that's the case, you can run the command on all (jpeg) files like so: exiftool -r '-DateTimeOriginal<FileModifyDate' -ext jpg DIR.

Hope this helps and please come back to us if you have any more questions!

P.S. If you have taken any pictures outside your local timezone, the times might be off (DateTimeOriginal is always the local time at the location where you shot the picture, file system times are local to where you are now). But this can be corrected with exiftool too, of course. This is another reason to not use the e.g. FileModificationTime as time of shot.
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hayo is right.  I don't know how the filesystem creation date can be after the modification date because I thought OS X didn't allow this.  I should have asked for this too as well as -time:all to be sure.

But if it is true, then maybe a command like this would push the file creation date back again:

exiftool -tagsfromfile @ -filemodifydate DIR

Maybe you could test this on a copy of one of your files.

As well, Hayo is right that it would be best to put this information inside your file, because otherwise it will eventually be lost (as you have already seen).

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

findlay70

@ Hayo @ Phil,
You guys are my heroes.This worked like magic.
cexiftool -tagsfromfile @ -filemodifydate DIR

Now I have another issue. I created a test file and any image in that folder worked. But when I extended the path to other subfolder, things got messy. for example:
/Users/Andy/Documents/FromCD's/CLOSED/My Pictures/My Family/TO FILE

I get a ">" as output... seems like something stalled. I tried various path names, but noting seemed to work.

Is there any way to add something to the command that looks for all JPEG files only in any/all subfolders within /Users/Andy/Documents/FromCD's/

Thanks again for your incredible help.
Andy

Hayo Baan

You need to put a backslash in front of the ' and all spaces otherwise it won't work. Alternatively enclose the whole path in double quotes. (For the command line, the quote is the start of a string and requires a matching end and spaces separate arguments, "escaping" them with a backslash will remove this special meaning)

Note that you still haven't solved your problem completely for the future. For that you really need to embed the creation date into the file as metadata as both Phil and I suggested.
Hayo Baan – Photography
Web: www.hayobaan.nl

findlay70

Thanks Hayo,
I tried your suggestion, i.e.
exiftool '-DateTimeOriginal<FileModifyDate' /Users/Andy/Documents/Test
Each file was renamed with today's created and modified date and a second file (duplicate was created) and renamed file.jpg.original. So that was a little messy. I checked the EXIF data of the new file and the EXIF data is empty apart from modify and create date..

It will probably be easier to pull the files from each subdirectory and drop them into an edit file this way I can watch each one and dont need to re-create a path. I was hoping that the command could look for all files within a location and subfolder/s, etc...
Thanks again..

StarGeek

Quote from: findlay70 on January 10, 2017, 05:20:04 PMa second file (duplicate was created) and renamed file.jpg.original.

Once you think the command is correct, you can add -overwrite_original to avoid the backup files.  To remove any originals that are still there, run exiftool -delete_original! FileOrDir to remove them.

QuoteIt will probably be easier to pull the files from each subdirectory and drop them into an edit file this way I can watch each one and dont need to re-create a path. I was hoping that the command could look for all files within a location and subfolder/s, etc...

Add -r to recurse into subdirectories.

So your final command would look like this:
exiftool '-DateTimeOriginal<FileModifyDate' -r -overwrite_original /Users/Andy/Documents/Test
"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

findlay70

Thanks Star Geek.. appreciate the support.
Many thanks mot Phil for the development of the tool and those that have helped me today... all very kind and generous.
Andy

Phil Harvey

Don't forget to add the -P option to preserve the original FileModifyDate.

Also, to avoid having to escape the spaces and apostrophe's yourself, you can just drop the folder onto the Terminal window instead of typing its name.

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

findlay70

Quote from: StarGeek on January 10, 2017, 05:36:45 PM
So your final command would look like this:
exiftool '-DateTimeOriginal<FileModifyDate' -r -overwrite_original /Users/Andy/Documents/Test

SG - this doesnt seem to work...I get the following error...

Warning: Error opening file - /Users/Andy/Documents/Test
Error: File not found - /Users/Andy/Documents/Test
    0 image files updated
    1 files weren't updated due to errors

findlay70

Quote from: Phil Harvey on January 10, 2017, 09:24:49 PM
Also, to avoid having to escape the spaces and apostrophe's yourself, you can just drop the folder onto the Terminal window instead of typing its name.

Hi Phil - I dragged the folder to the window, but it just showed the last subfolder - didn't give a path. Just the folder name...