ExifTool Forum

ExifTool => Newbies => Topic started by: Joseph Allan on April 28, 2013, 10:37:25 PM

Title: Set the file modification and creation date from EXIF info
Post by: Joseph Allan on April 28, 2013, 10:37:25 PM
Hi.  I have been trying to work out the command line to set the file modification and creation date in Windows from EXIF information.  It's listed as one of the features I cannot find any examples or any gui programs that will do it for me.  The reason for doing this that Adobe Photoshop Lightroom does not pick up the EXIF information in VIDEO files and uses either the file modification or creation date for capture time (can't remember which).  To get around this I use ROBOCOPY to preserve the dates - but my new Samsung S3 does not allow a drive letter connection (must connect using MTP Media Transfer Protocol).  When transferring the files from the phone Windows gives a new modified and created date.

Can anyone help?
Title: Re: Set the file modification and creation date from EXIF info
Post by: StarGeek on April 29, 2013, 04:02:30 AM
Quote from: josephallan on April 28, 2013, 10:37:25 PM
Hi.  I have been trying to work out the command line to set the file modification and creation date in Windows from EXIF information.

Check out Faq question 24 (http://www.exiftool.org/faq.html#Q24), esp. near the end.

Basically, I think you want something like

ExifTool "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal"  file

Though it's late right now for me, my brain is a bit fuzzy, and I'm not quite sure on which would be the correct tag you want to put in there.  Hopefully that will give you something to start with.
Title: Re: Set the file modification and creation date from EXIF info
Post by: Joseph Allan on April 29, 2013, 11:56:21 PM
Thanks!  I followed the FAQ to first produce a list of where the dates are stored then updated the file. 


D:\temp\vids\x>exiftool -time:all -a -G0:1 -s a.mp4
[File:System]   FileModifyDate                  : 2013:04:28 09:35:16+12:00
[File:System]   FileAccessDate                  : 2013:04:29 14:06:03+12:00
[File:System]   FileCreateDate                  : 2013:04:29 14:06:03+12:00
[QuickTime]     CreateDate                      : 2013:04:20 01:28:07
[QuickTime]     ModifyDate                      : 2013:04:20 01:28:07
[QuickTime:Track1] TrackCreateDate              : 2013:04:20 01:28:07
[QuickTime:Track1] TrackModifyDate              : 2013:04:20 01:28:07
[QuickTime:Track1] MediaCreateDate              : 2013:04:20 01:28:07
[QuickTime:Track1] MediaModifyDate              : 2013:04:20 01:28:07
[QuickTime:Track2] TrackCreateDate              : 2013:04:20 01:28:07
[QuickTime:Track2] TrackModifyDate              : 2013:04:20 01:28:07
[QuickTime:Track2] MediaCreateDate              : 2013:04:20 01:28:07
[QuickTime:Track2] MediaModifyDate              : 2013:04:20 01:28:07

D:\temp\vids\x>exiftool "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" a.mp4
    1 image files updated
Title: Re: Set the file modification and creation date from EXIF info
Post by: Joseph Allan on May 01, 2013, 04:31:39 AM
Hi.  I am now trying to run this on a directory, but I keep getting "0 image files read".  It works fine if I enter in a single .mp4 file but does not pick them up if using the -r option.

D:\temp\vids\x>exiftool "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" -r D:\temp\vids\x\Camera
    1 directories scanned
    0 image files read


And the single file...

D:\temp\vids\x>exiftool "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" D:\temp\vids\x\Camera\20130330_180321.mp4
    1 image files updated


What am I doing wrong? Thanks.
Title: Re: Set the file modification and creation date from EXIF info
Post by: Joseph Allan on May 01, 2013, 04:53:52 AM
Ok... Worked it out. Need to specify the file extension.

D:\>exiftool "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" -ext .mp4 -r D:\temp\vids\x\Camera
    1 directories scanned
   11 image files updated


The default is to process only supported files, but changing the file creation and modify dates do not change the files themselves - so should be ok with video files.  Is that right?
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on May 01, 2013, 08:05:47 AM
Right.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: airdrummer on August 24, 2013, 12:31:54 PM
i recently replaced my dead flipphone w/ an LG  ( i'm cheap; i'll get an iphone when my daughter upgrades to a 5;-) it's a real p.o.s.: not only are the filenames in mmddyyyy format off by 10 years(hey the phone isn't_that_old)-:

> ls -l 0818031904a.jpg
-rwxrwxrwx  1 tomw  admin  539476 Aug 18 23:04 0818031904a.jpg

but the stored exif dates are in a non-standard format:

> exiftool -FileModifyDate -DateTimeOriginal 0818031904a.jpg
File Modification Date/Time  : 2013:08:18 23:04:16-04:00
Date/Time Original              : 08.18.2013 19:04:15

which of course means this fails:

> exiftool "-FileModifyDate<DateTimeOriginal" 0818031904a.jpg
Warning: Month '18' out of range 0..11 in File:FileModifyDate (ValueConvInv) - 0818031904a.jpg
Warning: No writable tags set from 0818031904a.jpg
    0 image files updated
    1 image files unchanged

the -d FMT, -dateFormat is for output only, right? so do i have to extract/parse/reset the exif date in a 3-step shell process, or is there some way exiftool can do it in 1 swell foop?-)
Title: Re: Set the file modification and creation date from EXIF info
Post by: StarGeek on August 24, 2013, 03:17:07 PM
I just used the following command to fix your date/time original problem:
exiftool "-datetimeoriginal<${datetimeoriginal;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}" <file or dir>

but it also threw a Warning: [minor] Entries in IFD0 were out of sequence. Fixed., so maybe there's some other problems with the file.

Also, CreateDate suffers from the same date ordering problem, so you might want to fix that as well.  To do it all in one shot:
exiftool "-DateTimeOriginal<${DateTimeOriginal;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}" "-CreateDate<${CreateDate;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}"  "-FileModifyDate<${DateTimeOriginal;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}"  <file or dir>

Make sure and test it first, seemed to work fine here.

Edit: Added FileModifyDate to final command
Edit 2: Fixed derp moment on substitution ordering, now it should be correct
Title: nice, thanx:-)
Post by: airdrummer on August 24, 2013, 03:44:52 PM
i wasn't familiar w/the <${srcTag;s/regex/regex/} construct...if it's in phil's docs somewhere i musta skimmed right past it...the downside of reams of docs;-)

d'oh!-( what shell? just tried both omm:

> exiftool "-datetimeoriginal<${datetimeoriginal;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}" 0818031904a.jpg
-bash: -datetimeoriginal<${datetimeoriginal;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}: bad substitution
> exiftool -ver9.35
> uname -a
Darwin toms-MacBook-Pro.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64


Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on August 24, 2013, 06:29:11 PM
Use single quotes on Mac/Linux, not double quotes.  bash interpolates variables (starting with a "$") inside double quotes.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: StarGeek on August 24, 2013, 06:30:55 PM
Sorry, bad assumption on my part, passed right over where you used ls for the directory listing.  I use windows which uses double quotes.  For mac/linux, use single quotes.  Try this?

exiftool '-DateTimeOriginal<${DateTimeOriginal;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}' '-CreateDate<${CreateDate;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}' '-FileModifyDate<${DateTimeOriginal;s/(\d{2})\.(\d{2})\.(\d{4}) (.*)/$3:$1:$2 $4/}' <file or dir>

As for the docs, you'll find it under the -p FMTFILE or STR (-printFormat) section (http://www.exiftool.org/exiftool_pod.html#str) (look for the "advanced formatting" line).
Title: Re: Set the file modification and creation date from EXIF info
Post by: airdrummer on August 24, 2013, 07:18:43 PM
d'oh! didn't even think about the quotes...i've spent the last week banging on mysql, which doesn't care, and bash does...i knew that2 weks ago;-}

thanx v.much 4 ur help...th'intarwebs'll save me from my crss/ol'timer's!-)
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 14, 2014, 06:43:52 PM
I'm resurrecting this topic because it is similar to what I want to do.

I have a couple thousand mostly very old scanned photos that I have been putting together in Photoshop Elements Organizer over the last 10-12 years. I set the date of the original photo with Organizer's Date and Time tag, which stores in the DateTimeOriginal EXIF tag. Organizer allows addition of a partial date, e.g., year only, in which case the remainder or blank portion of the input is set as 00s in the DateTimeOriginal tag. I typically select these photos by keyword tags and view them in Date order. I am readying the jpgs for viewing online, and also need to be able to sort the files by this original photo date in this environment.

It would be a simple matter of updating the FileCreateDate and/or FileModifyDate to match the DateTimeOriginal  tag. But when I attempt to do this, ExifTool sees the zeros in the DateTimeOriginal tag as invalid, and the operation aborts with an error. (I can successfully use another ExifTool function to rename the file with the date at the beginning, but the date ends up incorrect. For example, a DateTimeOriginal date of 1912, no month, day, etc., would end up as 1911-11-01.)

What I am looking for is some ideas about how to solve this. I would like to use as much of the date as is in the tag, perhaps padding the remainder with some false additional components, (e.g. this 1912 may become 1912-01-01), or whatever might be possible with ExifTool.

Ideas?
DaveD
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on June 14, 2014, 07:39:49 PM
Hi Dave,

Would it do what you want to replace a month/day of "00:00" with "01:01"?  If so, try this:

exiftool "-filemodifydate<${datetimeoriginal;s/(\d{4}):00:00/$1:01:01/}" FILE

where FILE is one or more directory and/or file names.  Use single quotes instead of double if you are on Mac or Linux.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 14, 2014, 08:00:11 PM
Hi Phil, thanks for the quick response.

That would work, but only for those situations where only the year is filled in, as I read it. In many cases I have a month and day, sometimes a time. Since I need to batch process, it would have to work in all cases. Perhaps I could read the data into a file, post-process it, and then write the results back. But that would be difficult with my limited experience with your tool. BTW, I am using the ExifToolGUI, but through its command line, if that makes a difference.
DaveD
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on June 15, 2014, 06:30:21 AM
Hi Dave,

I'm sure ExifTool can do what you want, but to give more specific help I will need examples of all of the combinations of input date/time formats and what you want them converted to.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 15, 2014, 08:45:41 AM
Phil, I'm collecting a bunch of date info in this manner:
exiftool -time:all -a -G0:1 -s
I can give you the output examples as
EXIF:ExifIFD (example: [EXIF:ExifIFD]  DateTimeOriginal                : 1942:  :   00:00:00)
or XMP XMP-exif (example: [XMP:XMP-exif]  DateTimeOriginal                : 1942).
I expect you want the EXIF:ExifIFD version, but please let me know so I include the right stuff.
Depending upon how much of the date I entered, the version of Elements I used and whether it was a scan or photo, there are a lot of combinations
Dave
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on June 15, 2014, 08:48:43 PM
Hi Dave,

Using the EXIF version may be easier. 

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 16, 2014, 09:13:36 AM
Hi Phil,

What I would like to accomplish, all in batch mode, is to take whatever DateTimeOriginal metadata is included and round it out with a complete Date/Time entry (perhaps placing any digit that would return a valid date/time in the fields that are currently blank or "00") so I can move DateTimeOriginal into the FileCreateDate and/or the FileModifyDate without error. Then any online viewing application would be able to sort by what will then amount to the original date (as I stated in my original entry).

I've included the file date information from a number of scans. Most if not all of these were scanned as TIFs; I batched saved JPG copies with Photoshop several days ago in preparation for placing them online. The metadata is always duplicated properly to the JPG copy. Since only DateTimeOriginal appears to be relevant, I've included only that in the samples below.

The original date of each photo was input into Photoshop Elements Organizer by me when I scanned the photo, and that value went into DateTimeOriginal (sometimes--see below >:(). Over the years that I have been doing this I have used three Elements versions--3, 5, and 9--which appear to have used different methods to store date information.

Where I have entered a complete date and time it looks like this:
[EXIF:ExifIFD]  DateTimeOriginal                : 1985:09:15 18:02:20
The following samples were photo dates input with Elements 3.0 and 5.0:
[EXIF:ExifIFD]  DateTimeOriginal                : 1967:  :   00:00:00
[EXIF:ExifIFD]  DateTimeOriginal                : 1910:01:   00:00:00
[EXIF:ExifIFD]  DateTimeOriginal                : 1905:01:01 00:00:00


However, in scans that were done with Elements 9.0, DateTimeOriginal is not set at all. I have found some complaints online about that, but it is unclear whether this is a bug or a feature (Adobe always advertised that they wrote the metadata directly to the file and they don't appear to keep sidecars, but Adobe support is so poor that it's impossible to tell whether they mean to do it this way in 9.0). So I will also need to find a way to separate out those jpgs with no DateTimeOriginal tag so I can process them separately (using tag Creator Tool  : Elements Organizer 9.0). Luckily not too many scans have been made with 9.0.

Finally, taking the close look at Adobe Photoshop Elements that I was forced to do in these last few days has exposed some real uglies on the underbelly of that product. I have been considering moving away from PE for some time, but I believe I now have the impetus to do so. So I need some advice about where to go. I'm not at all a fan of Adobe for various reasons, mostly the problems they have caused in my Android world by no longer supporting Flash Player, but also lots of others, so would like to go somewhere else entirely. Suggestions, anyone?

DaveD
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on June 16, 2014, 10:02:53 AM
Hi Dave,

Thanks.  Try this:

exiftool "-filemodifydate<${datetimeoriginal;s/  /01/g}" FILE

Note that depending on your system you may or may not have success setting filesystem times to a date before 1970.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 16, 2014, 02:40:59 PM
Phil,
No success.
Here's the log:
Grabbed all time info from sample.jpg:
[File:System]   FileModifyDate                  : 2014:06:14 11:11:37-04:00
[File:System]   FileAccessDate                  : 2014:06:14 11:11:37-04:00
[File:System]   FileCreateDate                  : 2014:06:14 11:11:37-04:00
[EXIF:IFD0]     ModifyDate                      : 1967:00:00 00:00:00
[EXIF:ExifIFD]  DateTimeOriginal                : 1967:  :   00:00:00
[EXIF:ExifIFD]  CreateDate                      : 1967:00:00 00:00:00
[XMP:XMP-xmp]   CreateDate                      : 2014:06:13 11:10:27-04:00
[XMP:XMP-xmp]   MetadataDate                    : 2014:06:13 11:10:27-04:00
[XMP:XMP-xmp]   ModifyDate                      : 2014:06:13 11:10:27-04:00
[XMP:XMP-exif]  DateTimeOriginal                : 1967
[XMP:XMP-exif]  DateTimeDigitized               : 1967:02
[ICC_Profile:ICC-header] ProfileDateTime        : 1999:06:03 00:00:00
<-END-

Entered on ExifToolGUI command line: "-filemodifydate<${datetimeoriginal;s/  /01/g}"
Log message:
======== ./sample.jpg
Nothing changed in ./sample.jpg
    0 image files updated
    1 image files unchanged
Warning: No writable tags set from ./sample.jpg
<-END-
         

And, I couldn't for the life of me determine just what your ExifTool options were all about. Would it be possible to give a short description of the syntax used? It would go a long way for me understanding how to use this tool.
Thanks,
Dave                 
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on June 16, 2014, 02:59:04 PM
Hi Dave,

You must be using a very old version of ExifTool.  You must use version 9.30 or later for the advanced formatting feature.  The basic redirection syntax is explained in the -tagsFromFile section of the application documentation, which refers to the -p option for a description of the advanced formatting feature.  The expression I used substitutes all instances of "  " for "01" in the value of DateTimeOriginal before it is copied to FileModifyDate.

- Phil

Edit:  Tried to explain better where to find this in the documentation.
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 16, 2014, 03:19:17 PM
Hi Phil,

I'm using the ExifTool Windows Executable 9.64 downloaded from your site yesterday. I'm looking at the documentation on https://exiftool.org/exiftool_pod.html#synopsis, and linking to examples.

But it's me. I haven't yet found the courage to explore this tool as I must if I am going to use it productively. I spent many productive years in IT accomplishing tasks using a command line interface, but I've become lazy in my old age after so many years of using GUIs.

So I'll spend some time trying to figure this one out from your short explanation above, and get back to you after I know a bit more. Unless, of course, you have some additional suggestions in the meantime.

Thanks again,
Dave
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on June 16, 2014, 03:26:01 PM
Hi Dave,

Another possible problem is that my quoting assumes you were using the Windows cmd shell.  In other shells you would need to use single quotes instead of double quotes around any argument containing a '$' symbol.

- Phil

Edit: Also, to make sure it takes the EXIF DateTimeOriginal, it would be best to do this:

exiftool "-filemodifydate<${exif:datetimeoriginal;s/  /01/g}" FILE
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 16, 2014, 04:49:27 PM
Phil,

This works:
exiftool "-createdate<${datetimeoriginal;s/  /01/g}".
No need to specify the EXIF tag in the case of datetimeoriginal (or createdate). But perhaps I need to specify the filesystem tag type for the filemodifydate? I haven't found how to do that. -file:filemodifydate and -file:system:filemodifydate don't work.

I'm using Windows, with double quotes. I also tried running ExifTool in a cmd window, same results. So ExifToolGUI isn't getting the way. Actually, its kind of nice to use the GUI ExifTool direct command line, as it makes for a lot less typing, like entering my rather long file names with spaces inside quotes, etc.

Dave

Edit: Well now, I tried a new photo, taken in 2012, and it worked just like it should, setting the file system modified date to 1/1/2012 12:00 AM (as displayed in Windows) from a DateTimeOriginal date of 2012:  :   00:00:00. I don't believe that Windows has an date epoch anywhere within the last several hundred years--it appears to be 1 January 1601. Could it be Perl causing this? Perl has a date epoch of 1 January 1970 (http://en.wikipedia.org/wiki/System_time) (http://en.wikipedia.org/wiki/System_time). Or is it something else?
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on June 16, 2014, 08:32:43 PM
Right.  The 1970 problem as I mentioned.

The standard C library functions which are the basis of the Perl libraries use a time zero of 1970.  On some systems though (typically 64-bit systems), negative times are allowed.  But the Windows .exe version of ExifTool is not 64 bit.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: dld44 on June 17, 2014, 08:03:45 AM
Rats! I was so close to getting it done. I tried a few more samples, on both sides of 1/1/1970, and verified that this is indeed the problem. So on to plan "B", although I have not yet identified just what that might be. At least I can get the invalid dates straightened out with ExifTool's substitution capability.

Thanks for all your assistance.
Dave
Title: Re: Set the file modification and creation date from EXIF info
Post by: babyphat1 on September 17, 2017, 08:39:38 AM
Hello Phil,

I've tried the following for my video but seems like there is no data. So how am I supposed to change it to its original time?

C:\Users\watev>exiftool -time:all -a -G0:1 -s C:\Users\watev\Desktop\Video047.mp4
[File:System]   FileModifyDate                  : 0000:00:00 00:00:00
[File:System]   FileAccessDate                  : 0000:00:00 00:00:00
[File:System]   FileCreateDate                  : 0000:00:00 00:00:00
[QuickTime]     CreateDate                      : 0000:00:00 00:00:00
[QuickTime]     ModifyDate                      : 0000:00:00 00:00:00
[QuickTime:Track1] TrackCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track1] TrackModifyDate              : 0000:00:00 00:00:00
[QuickTime:Track1] MediaCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track1] MediaModifyDate              : 0000:00:00 00:00:00
[QuickTime:Track2] TrackCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track2] TrackModifyDate              : 0000:00:00 00:00:00
[QuickTime:Track2] MediaCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track2] MediaModifyDate              : 0000:00:00 00:00:00

What should I do about this?
Any help?
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on September 18, 2017, 08:59:51 AM
There seems to be no date/time information available here.  In this case you must set it manually, ie)

exiftool -wm w -time:all="2017:09:17 08:00:00" FILE

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 20, 2018, 01:45:13 PM

Hi everyone,
I'm trying to do something like you did in this post, obviously without luck.

I would like to copy the 'Data Created' to the 'Data Time Original' field of Adobe Bridge (image attached).

I used the following command:

exiftool '-datetimeoriginal<createdate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' *


The output is:


Warning: No writable tags set from DailyLife00321.jpg
Warning: No writable tags set from DailyLife00322.jpg
    0 image files updated
    2 image files unchanged


Thank you guys
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on February 20, 2018, 01:53:41 PM
It seems that CreateDate is not available.

To see the available date/time tags, use this command:

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

Also, I would suggest using the -ext option instead of testing FileType to avoid needlessly parsing non-jpeg files:

exiftool '-datetimeoriginal<createdate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 20, 2018, 02:21:24 PM

Thank you Phil.

You were right, I got this output:


MacBookProWireless:test myname $ exiftool -a -G1 -s -time:all DailyLife00321.jpg
[System]        FileModifyDate                  : 2018:01:29 18:55:09+01:00
[System]        FileAccessDate                  : 2018:02:20 20:06:53+01:00
[System]        FileInodeChangeDate             : 2018:02:20 20:06:51+01:00
[XMP-xmp]       MetadataDate                    : 2018:01:29 18:55:09+01:00
[XMP-xmpMM]     HistoryWhen                     : 2018:01:29 16:32:29+01:00, 2018:01:29 18:55:09+01:00


Then, do you maybe know how can I get the created data info?

I attached two images about the file that I am talking about to be clear.


Title: Re: Set the file modification and creation date from EXIF info
Post by: StarGeek on February 20, 2018, 03:01:21 PM
I haven't checked in a bit but when I looked at Adobe Bridge ver 7.0.0.93, the "Date Created" property was filled with these tags, in descending priority
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 20, 2018, 03:22:02 PM

Sorry StarGeek, but I am a beginner.
I found some of this tags in Adobe, but I have not idea how to fix the problem.

Do you have some advice for edit my command?

Title: Re: Set the file modification and creation date from EXIF info
Post by: StarGeek on February 20, 2018, 03:39:38 PM
Quote from: stefanoanzilotti on February 20, 2018, 03:22:02 PM
I found some of this tags in Adobe, but I have not idea how to fix the problem.

Sounds like I wasn't quite clear enough.  That list I gave is just the "Date Created" entry in Adobe Bridge.  Bridge will go down that list until it finds one of those tags and use that as the "Date Created"

QuoteDo you have some advice for edit my command?

Unfortunately, no.  I don't use a Mac so I have no idea where it is pulling it's "Date Created" property from.  It doesn't show up on the output you gave for the Time:All command, which I find really confusing.

Even though FileCreateDate doesn't show up on your output, maybe try to use it? 
exiftool '-DateTimeOriginal<FileCreateDate'
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 20, 2018, 04:07:37 PM
Quote from: StarGeek on February 20, 2018, 03:39:38 PM
Sounds like I wasn't quite clear enough. 

Everything is new for me right now (command line first), but I like it already.

Quote from: StarGeek on February 20, 2018, 03:39:38 PM
It doesn't show up on the output you gave for the Time:All command, which I find really confusing.

I really don't understand how could be possible that I see the real 'Created Data' in the finder, but I cannot see the info on the terminal.

Anyway, I trayed this command:

exiftool '-DateTimeOriginal<FileCreateDate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .


Still same output.   :(
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on February 20, 2018, 09:37:28 PM
On Mac, the file creation date is MDItemFSCreationDate.  See the MacOS tags (https://exiftool.org/TagNames/MacOS.html) for an explanation.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 21, 2018, 05:29:18 AM

As you said, I found the file creation date is MDItemFSCreationDate using the command:

$ mdls photoname.jpg

Maybe I can copy this value to 'DataTimeOriginal' field?
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on February 21, 2018, 07:16:53 AM
exiftool '-datetimeoriginal<MDItemFSCreationDate' -overwrite_original_in_place -P FILE

Here I have added -overwrite_original_in_place to prevent the file creation date/time from being set to the current time when the file is rewritten, and -P to preserve the file modification date/time.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 21, 2018, 09:01:32 AM

That's working amazingly! Thank you so much!

I would like also to skip the files that already have 'datatimeoriginal' field fixed. I trayed to marge the previous commands, but I got an error.

exiftool '-datetimeoriginal<MDItemFSCreationDate' -overwrite_original_in_place -P -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .

Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on February 21, 2018, 09:14:03 AM
It would help if you told me what the error was.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 21, 2018, 09:35:17 AM

The error is:


MacBookProWireless:test stefanoanzilotti$ exiftool '-datetimeoriginal<MDItemFSCreationDate' -overwrite_original_in_place -P -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .
    1 directories scanned
    2 files failed condition
    0 image files read


I thought about a syntax mistake.
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on February 21, 2018, 11:01:47 AM
So there was no error after all?  Just all files failed the condition.  To see why, take a look at DateTimeOriginal for these files.  If it exists and isn't all zeros, then the condition will fail.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 25, 2018, 04:09:57 PM

Then, I made some tests.
Actually, everything works right if the field 'DataTimeOriginal' is free. The command does not work if I manually delete the field for testing the command. I still do not figure out why that happened.

I really appreciated the help. Useful forum!  ;)
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on February 25, 2018, 05:22:58 PM

I was wondering other one question: is the opposite operation possible? In other words, I would like to set the 'Data File Created' as the 'DataTimeOriginal'?
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on February 25, 2018, 07:52:46 PM
Quote from: stefanoanzilotti on February 25, 2018, 04:09:57 PM
The command does not work if I manually delete the field for testing the command. I still do not figure out why that happened.

You don't get the same result when you try this on your system?:

$ exiftool -ver
10.80
$ exiftool a.jpg -datetimeoriginal=now
    1 image files updated
$ exiftool a.jpg -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -filename
    1 files failed condition
$ exiftool a.jpg -datetimeoriginal=
    1 image files updated
$ exiftool a.jpg -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -filename
File Name                       : a.jpg
$
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on March 06, 2018, 03:30:31 PM

I got the same result by your way, but If I delete the DataTimeOriginal field by Adobe Bridge the code does not work. That's really weird.

I spent a little time to set the Data File Created as the DataTimeOriginal, but I am still far to the solution. The code:

exiftool '-FileCreateDate<DateTimeOriginal' -overwrite_original_in_place -P -ext jpg -ext jpeg -ext gif -ext mp4 -ext mov .

gives me back this output:

Warning: This tag is Windows only in File:FileCreateDate (ValueConvInv) - ./Portugal00106.jpg
Warning: No writable tags set from ./Portugal00106.jpg
Warning: This tag is Windows only in File:FileCreateDate (ValueConvInv) - ./Portugal00105.jpg
Warning: No writable tags set from ./Portugal00105.jpg
    1 directories scanned
    0 image files updated
    2 image files unchanged


I understood that is not possible write over this field. Right?
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on March 06, 2018, 09:45:29 PM
On the Mac, the filesystem creation time is accessed through MDItemFSCreationDate (https://exiftool.org/TagNames/MacOS.html).  FileCreateDate is Windows only.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on March 07, 2018, 06:22:26 AM

Then, by the command:

exiftool '-MDItemFSCreationDate<DateTimeOriginal' -overwrite_original_in_place -P .

the output is:


exiftool '-MDItemFSCreationDate<DateTimeOriginal' -overwrite_original_in_place -P .
>


What should I do?


Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on March 07, 2018, 08:13:12 AM
I think your quoting is funny.  Try using normal ASCII single quotes.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on March 07, 2018, 08:27:22 AM

I agree with you that is funny!

Code:
exiftool '-MDItemFSCreationDate<DateTimeOriginal' -overwrite_original_in_place -P -ext jpg -ext jpeg -ext gif -ext mp4 -ext mov .

Output:

Warning: Error 256 running "setfile" to set MDItemFSCreationDate - ./b.jpg
Warning: Error 256 running "setfile" to set MDItemFSCreationDate - ./a.jpg
    1 directories scanned
    0 image files updated
    2 files weren't updated due to errors
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on March 07, 2018, 08:30:10 AM
What version of OS X are you running?  You need to have the "setfile" utility available to be able to write MDItemFSCreationDate.  I thought this was a standard OS X utility.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: stefanoanzilotti on March 07, 2018, 08:41:03 AM

v10.13.3

Then I am going to find out a way to activate that! thank you man
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on March 07, 2018, 08:45:10 AM
Ah.  It comes with the XCode developer tools (see here (https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/SetFile.1.html)).  I hope you don't have to install the full XCode -- the download size is massive.

- Phil

Edit: Here is a post (http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/) that shows how to install the tools without installing the full XCode for an older version of OS X.  Maybe it still applies.

Or in case you can run it directly, I have attached the setfile binary to this post.  This is from my 10.13.3 installation, so it should work as long as it doesn't rely on other developer libraries.

Edit2: Here are the libraries it depends on:

> otool -L /usr/bin/setfile
/usr/bin/setfile:
   /usr/lib/libxcselect.dylib (compatibility version 1.0.0, current version 1.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
Title: Re: Set the file modification and creation date from EXIF info
Post by: jmv on October 01, 2018, 03:29:30 AM
Quote from: Phil Harvey on May 01, 2013, 08:05:47 AM
Right.

- Phil

How do you run an equivalent command but not have exifTool execute the changes but rather get an output of what would be performed ?

Thanks
Title: Re: Set the file modification and creation date from EXIF info
Post by: Phil Harvey on October 01, 2018, 07:12:20 AM
If you are writing FileName, then there is the TestName tag.  Also, you can use the -if statement in another command to see which files may be processed.  But there is no dry-run option if that is what you want.

- Phil
Title: Re: Set the file modification and creation date from EXIF info
Post by: jmv on October 01, 2018, 12:03:10 PM
Super! Thanks Phil !

And great work building that ExifTool :)