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

StarGeek

There should be a space after the quote and before the slash that is the start of the file path.

* 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).

Stephen Marsh

#31
EDIT: Ah, I did not see StarGeeks reply!

exiftool '-datetimeoriginal+<0:$filesequence'/Users/Andy/Desktop/wedding/1

Add a space before the directory path:

exiftool '-datetimeoriginal+<0:$filesequence' /Users/Andy/Desktop/wedding/1

If this is on a Mac and you did not drag the folder into Terminal.app you may also wish to enclose the directory path in single quotes too. This is not necessary in this case as there are no word spaces in the path, it is just good habit for paths that do not contain escaped word spaces:

'/Users/Andy/Desktop/wedding/1'

P.S. I am presuming that "1" is a folder?

StarGeek

Quote from: Stephen Marsh on September 06, 2017, 04:20:09 AM
EDIT: Ah, I did not see StarGeeks reply!

But you had a more complete answer than my lazy one :)
* 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).

halfasia


heatvent

Hi, I modified the above code for a similar use.  I have scanned slide jpg files sorted as follows P:\Processed\YEAR\Subject.  I use the following batch file to change the date taken the 1/1/YEAR 11:01 am and then increment each file by 1 minute.  This is mostly to get the files to show in the correct year for photo apps and to keep in sequence.  I have no idea of the actual date taken:)

Command to use (1963 as an example year):

ExifToolReDate.bat 1963

ExifToolReDate.bat Batch file code....


echo off

set YEAR=%1

echo Working on all files in P:\Processed\%YEAR%

echo Changing year for all dates in files...

exiftool -all= -AllDates="%YEAR%:01:01 11:01:00" -recurse -quiet -overwrite_original P:\Processed\%YEAR%

echo Incrementing all times by 1 minute...

exiftool "-AllDates+<0:${filesequence}" -recurse -quiet -overwrite_original P:\Processed\%YEAR%

echo Process completed!

suplemereader

Hello. exiftool is amazingly feature-rich, but i'm lost. Resurrecting the thread but looking for guidance.

I want to increment SubSecTimeOriginal to get a trailing digit on timestamps, as in DateTimeOriginal shown below.

$ exiftool -Time:All /Users/jrb8/Desktop/sortphotos_test/img___00001.jpg
File Modification Date/Time     : 2019:01:20 03:00:51-05:00
File Access Date/Time           : 2019:01:20 03:13:57-05:00
File Inode Change Date/Time     : 2019:01:20 03:00:51-05:00
Modify Date                     : 2000:09:13 20:20:03
Date/Time Original              : 2014:02:21 10:48:00
Create Date                     : 2000:09:13 11:40:49
Sub Sec Time Original           : 0
Date Created                    : 2000:09:13
Time Created                    : 11:40:49-05:00
Date/Time Created               : 2000:09:13 11:40:49-05:00
Date/Time Original              : 2014:02:21 10:48:00.0


I'm able to set an initial SubSecTimeOriginal value for every file in the directory...
$ exiftool -subsectimeoriginal="0" /Users/jrb8/Desktop/sortphotos_test/ -overwrite_original_in_place
1 directories scanned
10 image files updated


and a test run of the incrementing appears successful...
$ exiftool -p '0:$filesequence $filename' /Users/jrb8/Desktop/sortphotos_test/
0:0 img___00001.jpg
0:1 img___00002.jpg
0:2 img___00003.jpg
0:3 img___00007.jpg
0:4 img___00006.jpg
0:5 img___00004.jpg
0:6 img___00010.jpg
0:7 img___00005.jpg
0:8 img___00008.jpg
0:9 img___00009.jpg


But I cannot get the final piece of it to run successfully...  $ exiftool '-subsectimeoriginal+<0:$filesequence' /Users/jrb8/Desktop/sortphotos_test/ -overwrite_original_in_place
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00001.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00002.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00003.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00007.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00006.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00004.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00010.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00005.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00008.jpg
Warning: No writable tags set from /Users/jrb8/Desktop/sortphotos_test/img___00009.jpg
    1 directories scanned
    0 image files updated
   10 image files unchanged



Any help is greatly appreciated.

Phil Harvey

SubSecTimeOriginal is a single number, not a date/time value. So shifting is done like this:

$ exiftool '-subsectimeoriginal+<filesequence' /Users/jrb8/Desktop/sortphotos_test/ -overwrite_original_in_place

But if you want to start from zero, and don't care about the existing values, the "+" isn't necessary:

$ exiftool '-subsectimeoriginal<filesequence' /Users/jrb8/Desktop/sortphotos_test/ -overwrite_original_in_place

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

suplemereader

Thank you Phil, helped a lot!

Is there a way with exiftool to have filesequence generate x number of digits and leading zeros?

For example, if I wanted a 3-digit filesequence result...
iterations 0-9
000, 001, --> 009

iterations 10-99
010, 011,  --> 099

iterations 100-999
100, 101,  --> 999

StarGeek

See this this previous post for three examples.  Just change FileIndex to FileSequence and change the 5 to 3.
* 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).

suplemereader

Hi Stargeek,

Thank you for the pointer to that posting, but I am still missing something.

After setting the SubSecTime manually on my test files, I tried some of those solutions with the following results:

exiftool -P '-subsectimeoriginal<${filesequence;$_=substr('000'.$_,-3)}' '-subsectimedigitized<${filesequence;$_=substr('000'.$_,-3)}' /Users/jrb8/Desktop/sortphotos_test_2 -overwrite_original_in_place

$ exiftool -subsectime -subsectimeoriginal -subsectimedigitized /Users/jrb8/Desktop/sortphotos_test_2
======== /Users/jrb8/Desktop/sortphotos_test_2/001.jpg
Sub Sec Time                    : 1
Sub Sec Time Original           : 00
Sub Sec Time Digitized          : 00
======== /Users/jrb8/Desktop/sortphotos_test_2/011.jpg
Sub Sec Time                    : 11
Sub Sec Time Original           : 01
Sub Sec Time Digitized          : 01
======== /Users/jrb8/Desktop/sortphotos_test_2/111.jpg
Sub Sec Time                    : 111
Sub Sec Time Original           : 02
Sub Sec Time Digitized          : 02



I was hoping to get a 3-digit value for both SubSecTimeOriginal and SubSecTimeDigitized. Anything jump out to you as a mistake in my syntax?

StarGeek

Since you appear to be on Mac/Linux, you probably need double quotes around the 0s.  Otherwise, it looks like bash gets in the way and simplifies string 000 to numeric 0.  Just a guess though.
* 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).

Phil Harvey

Yup.  The quoting is the problem.  It isn't bash, but Perl that is doing it.  Without the quotes around "000", it is interpreted as a number.

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

suplemereader

Gentlemen,

Thank you both kindly. It's working like a charm now.

ceej

Newbie here; very rusty programmer; have also read similar topic in StackExchange but cant find it now. Some of what I include here is from there.  Anyway -

I have a directory of several thousand scanned photographs.
Each has a metadata value of DateCreated/DateTimeOriginal = yyyy/mm/dd-00:00:00 (however it is actually encoded) that was written with each scan.  Large 'bunches' of photographs have the same value.
The date is important - it is 'pretty accurate' and I'd like to keep it.
But the time values for all of the files is 00:00:00

What I would like to do is set the time value to successive 10-second increments.  (this is primarily to insure that various photo apps/services will display the photos in the scanned sequence)
Since there are 24*360=8640 10-second increments in a day, I do not have enough photos of the same day that there would be a conflict.

And I do not need to reset the time value whenever I start a new date (though that would be an added bonus).

So will the (pseudo) code below work?

@echo off
setlocal EnableDelayedExpansion (copied from an example; not clear i need it)
n=0
for %%f in (*.jpg) do (
    echo %%f
   n=n+10
    rem Assign time increment
    exiftool -DateTimeOriginal+="00:00:n" %%f  (not sure if time format is correct)
)

Big question, I guess is: as n grows, will the "00:00:n" take on the proper form?  That is:
n=50   "00:00:n" = 00:00:50
n=60   "00:00:n" = 00:01:00
n=120   "00:00:n" = 00:02:00
n=600   "00:00:n" = 00:10:00
n=3599   "00:00:n" = 00:59:59
n=3600   "00:00:n" = 01:00:00
n=3601   "00:00:n" = 01:00:01
n=8639   "00:00:n" = 23:59:59
n=8640   "00:00:n" = 00:00:00 and will it bump the day number?

If I wanted 1-minute increments, would I use n+n+1 and "00:n:00" ?
Thanks,
  -ceej

StarGeek

Quote from: ceej on March 23, 2021, 07:42:52 PM
Newbie here; very rusty programmer; have also read similar topic in StackExchange but cant find it now. Some of what I include here is from there.

Here's the post you're looking for.  It's based upon the second post in this thread.

QuoteSo will the (pseudo) code below work?

Running exiftool in a loop is always a bad idea, as its biggest performance hit is the startup time.  Running it over several thousand images could take hours this way when letting exiftool do the work itself would take a fraction of that time.  See Common Mistake #3

The command you want to run would be the one listed on the StackExchange post, but changing the single quotes to double quotes since you appear to be on Windows (but use single quotes in PowerShell, I believe)
exiftool "-datetimeoriginal+<0:0:${filesequence}0" DIR

QuoteBig question, I guess is: as n grows, will the "00:00:n" take on the proper form?

Yes.  Using the format 0:0:n will increment the the timestamp by the number of seconds, no matter if the number is 1 or 31.6 million (about a year)  .  In the above example, it uses the FileSequence tag, which is a counter incremented for each source file (see Extra tags).

QuoteIf I wanted 1-minute increments, would I use n+n+1 and "00:n:00" ?

You would use
"-datetimeoriginal+<0:${filesequence}:0"
in the above command.

For further details on shifting times with exiftool, see ExifTool Date/Time Shift Module.
* 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).