News:

If this site goes down it is because of the crappy DreamHost web hosting: They will disable your "unlimited traffic" web server if a single bot hammers the site with a moderate load.  If necessary, an alternate ExifTool forum page is available at https://sourceforge.net/p/exiftool/discussion/

Main Menu

How to increment file creation date from file to file

Started by Arni, February 21, 2014, 10:38:49 AM

Previous topic - Next topic

Arni

Hello,

I'm from Germany and have many JPG files that doesn't contain any EXIF information.
For all of these files I want to assign a specific EXIF creation date/time
that is incremented by a specific amount (maybe 1 minute) from file to file,
using an alphabetical order by their file name (from "A" to "Z").

If there is any way, how can I do this using the command-line application "exiftool"?
(Operating system is Mac OS X 10.6.8 "Snow Leopard".)

I've already installed exiftool on my Mac Pro successfully and would be profoundly
grateful for any help and answer to the issue.


Arni

Phil Harvey

Hi Arni,

This is a bit tricky, but you could do this with 2 commands:

1) First set all images to the same date/time:

exiftool -datetimeoriginal="2014:02:21 10:48:00" DIR

2) Increment the times by one additional minute for each file:

exiftool '-datetimeoriginal+<0:$filesequence' DIR

where DIR is a directory containing the images.  (You must use single quotes instead of double quotes around the argument in the second command since you are running on a Mac.) The +< syntax copies the value of other tags and uses it to increment the target tag, and the format for incrementing minutes is "0:MM".  Here, I have used the Extra FileSequence tag to give me the incrementing values that we need.

On a Mac, the files will be processed in alphabetical order, so you don't need to worry about this.  (ie. specifying -fileorder FileName should not be necessary.)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Arni

Hi Phil,

I tested your code and it works great.
Also, I modified your code a little bit so it works recursively for all file times, incrementing seconds instead of minutes.


exiftool -all= -AllDates="2000:01:01 00:00:01" /Users/Arni/Desktop/Test -i SYMLINKS -overwrite_original -r
exiftool '-AllDates+<0:0:$filesequence' /Users/Arni/Desktop/Test -i SYMLINKS -overwrite_original -r
find /Users/Arni/Desktop/Test -type f -exec touch -c -t 200001010000.00 {} +


The only thing remaining is, that exiftool creates new files under the current date in the inode of the file system.
I added a command using "find" and "touch" to change file access/modification/creation times to 2000/01/01 00:00:00.00.
I would rather like to change them to the individual EXIF times that I have created for each file but I don't know how I can do this.
Have you any idea?

Arni

Phil Harvey

Hi Arni,

You have full control over the FileModifyDate after editing with exiftool.  Either use -P to preserve the original date/time, or set FileModifyDate to whatever else you want with an argument like -filemodifydate='2000:01:01 00:00:00' or '-filemodifydate<datetimeoriginal'.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Arni

Hi Phil,

I want the file creation/modify/access times of the file system's inode (HFS+) to be exactly the same value as the EXIF data for each file.
How can I do this?


Arni

Phil Harvey

Hi Arni,

ExifTool can not set the file creation or access time, but as I said you can set the FileModifyDate to anything you want.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Arni

Quote from: Phil Harvey on February 21, 2014, 01:49:04 PM
ExifTool can not set the file creation or access time, but as I said you can set the FileModifyDate to anything you want.

OK Phil, I understand.

The "touch" command could do this modifications. I think I need
to find a way to increase the date/time of "touch" from file to file
in the same way I did for the "exiftool" command.


Many thanks for your help!

Arni

Phil Harvey

I don't think that touch can set the file creation date either (tell me if I'm wrong about this), and setting the file access date is pretty-well useless (unless you're a hacker trying to cover your tracks), so I don't see the point in using touch.

The creation date can be set indirectly on the Mac.  See the FileCreateDate notes in the Extra tags documentation for details.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Arni

The "touch" command is actually to change the file access and modification times.
But if the modification time is set to a time before the creation time of the file,
it forces to be set the creation time as well.

Another way is to use the Apple developer tools command "SetFile".
-> https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/SetFile.1.html
-> http://hints.macworld.com/article.php?story=20011018172352562&query=creation+date

Arni

Phil Harvey

Hi Arni,

Quote from: Arni on February 21, 2014, 03:04:18 PM
The "touch" command is actually to change the file access and modification times.
But if the modification time is set to a time before the creation time of the file,
it forces to be set the creation time as well.

Yes.  ExifTool does this too.  (As explained in documentation I linked in my last post.)

- Phil

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Arni

Hi Phil,

Finally, I've got it down pat. I have tested your code and it works fine.
Here are the 3 commands that will do the job.


exiftool -all= -AllDates="2000:01:01 00:01:00" /Users/Arni/Desktop/Test -overwrite_original -r
exiftool '-AllDates+<0:$FileSequence' /Users/Arni/Desktop/Test -overwrite_original -r
exiftool '-FileModifyDate<DateTimeOriginal' /Users/Arni/Desktop/Test -r


Thanks a lot!


Arni

NT4Boy

Hi,

This is exactly what I need to do on my Windows box, but I cannot get this syntax to work.
I've a few hundred files, some have been edited and the metadata overwritten and my IPAD needs the DateTimeOriginal or CreateDate data to show things in a consistent order. (I think)

exiftool -AllDates="2014:02:21 10:48:00" c:\11\exif\pics -overwrite_original -r
exiftool -AllDates+<0:$filesequence C:\11\exif\pics\ -fileOrder FileName -overwrite_original -r

first line is fine and does what I expect,
the second line fails with "the system cannot find the path specified."

Appreciate some guidance please.

Thanks

StarGeek

Any time you use the '<' or '>' on windows, you need to put that part of the command in double quotes in order to avoid redirection.  If you check, you might have a file with AllDates in the filename in the directory you ran it from. 

Try this:
exiftool "-AllDates+<0:$filesequence" C:\11\exif\pics\ -fileOrder FileName -overwrite_original -r
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

NT4Boy

Ah yes, that'll teach me to just cut and paste without reading and fully understanding.
You were of course correct, thank you.

Took quite a while to run through the 400 odd files, but now show in the required order. Excellent.

Hmm, I notice that in and amongst these jpg are a handful .mov files and I guess the Exif not able to deal with these in the same way.
Ipad originally filed them in sequence with the jpg and now all movies are all clustered together at the recent end of the folder.
More research I guess on how the Ipad decides when a movie was created and then how to put that in with the pictures...the tasks we get from our dearest and nearest's..!

StarGeek

Quote from: NT4Boy on March 11, 2014, 04:51:22 PMHmm, I notice that in and amongst these jpg are a handful .mov files and I guess the Exif not able to deal with these in the same way.

From FAQ 16

QuoteBy default, ExifTool only processes writable file types when any tag is being written and a directory name is specified on the command line. To force exiftool to process other files, they must either be listed on the command line by name, or be specified using the -ext option, something like this:

exiftool -ext AVI -ext JPG -d pics/%Y/%m "-directory<dateTimeOriginal" DIR

When a single -ext option is used, only files of the specified type are processed. However, multiple -ext options may be used in the same command (as in the example above) to process any number of different file types.

If you know everything in the directory can be processed, you can use -ext * to have it process all the files.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).