I have a collection of photos that have no date information. They have no Exif data, and the file modification dates are all identical. The only sequence is in the file name: image-0001.jpg, image-0002.jpg, etc.

Now I want to assign a date to these files (preferably in Exif) that are all 10 seconds apart. I'm not so interested in what exactly the base date and time will be, just that they all increment 10 seconds. So the first image will get 0:00:00, the second 0:00:10, the third 0:00:20, etc.

Is this possible with ExifTool, or other Windows applications? We're talking about several thousands of images, so doing this manually is out of the question ;-)


There's already a similar question on the ExifTool forums. It can be done using two sequential ExifTool commands. First, make sure all the date to the same

exiftool -datetimeoriginal="2015:02:22 00:00:00" DIR

And then increment the time on each

exiftool '-datetimeoriginal+<0:0:${filesequence}0' DIR
  • Hi StarGeek. How is this answer different from junkyardsparkle's one? – Saaru Lindestøkke Feb 22 '15 at 17:59
  • @Bart, here, $filesequence is a magic exiftool variable; in junkyardsparkle's, $file is a bash variable. This is more portable; the other ties the time to the filename rather than to the order exiftool happens to read them. – mattdm Feb 22 '15 at 18:36
  • Neat. I had a feeling exiftool could do something like that, but if it's in the docs, then I missed it. – junkyardsparkle Feb 22 '15 at 20:03
  • 2
    Also note that in bash ' vs " is significant — with double quotes, the $ will be caught and interpreted by the shell (as in Jens' answer), but in this answer it needs to be a single quote so it's interpreted by ExifTool internally. – mattdm Feb 22 '15 at 22:16
  • 1
    NOTE: You should also use "-fileorder FileName" in the increment command, otherwise the files may not actually be read in the expected order. – junkyardsparkle Feb 22 '15 at 23:45

Try Irfanview. It is freeware (AFAIR) and has a very flexible batch renaming system.

Other than that I would try writing a script, something along the lines of

for X in $(seq -w 0 20) ; do
  plus=$(expr $X \* 10)
  exiftool -alldates+="0:0:0 0:0:$plus" image_$X.jpg

The first line creates a loop through the numbers in the file names that you have, eg. 00..20. If you have 1000 images, the command would be seq -w 0 1000. The option -w adds leading zeros to the numbers.

The second line defines the increment - 10 in this case. Without units so far.

The format string in the third line "0:0:0 0:0:$plus" defines what the variable $plus means, in this case seconds. If you wanted minutes you'd write 0:0:0 0:$plus:0. The format is "year:month:day hour:minute:second". So here, we have a 10 second increment.

This is a batch done in 'bash' (Linux shell), you might have to adapt it to Windows or use a Linux live system to do the conversion.

Note that all files should have an (identical) Exif tag (DateTimeOriginal) before this can be used, since it increments the existing tags only. But you can simply write a tag with one exiftool command.

I tested this with 20 example files and the tags were correctly written.

  • Interesting that exiftool works with > 59 in the seconds field; cool. Other than that, and being a little shorter and cleaner, this is basically the same as my approach, except mine parses the index from the filename and yours generates the filenames from the index. In practical application, half a dozen of one and six of the other, I think. :) – mattdm Feb 20 '15 at 21:59
  • Thanks, and very true. When I started figuring this out there weren't any answers, so you were faster. :) – Jens Feb 20 '15 at 22:31

Well, I didn't post my bash answer because the question specifically asked about a Windows solution, but since two other people did, here's what I came up with:

for file in *.jpg
  exiftool -DateTimeOriginal="1111:11:11 00:00:00" $file
  exiftool -DateTimeOriginal+="00:00:${file:6:4}0" $file

Avoids messing with the date command. :)

Note that in the part where it says ${file:6:4}, the "6" represents the point in the filename where the sequence number starts, and the "4" represents the length of that sequence. If your files exactly match the "image-0001.jpg, image-0002.jpg" given in the question, this will work as is; otherwise, adjust to match.

  • That is way cooler than my solution. But it can still be a little optimized :) by calling the first exiftool only once on all files at once and looping only through the second command. (Right?) – Jens Feb 20 '15 at 22:56
  • Yeah, that would be more efficient. :P Anyway, your answer is much better pseudocode for anyone actually trying to port it to DOS or whatnot. I can't seem to avoid evil bashisms to save my life. – junkyardsparkle Feb 20 '15 at 23:26
  • 1
    "evil bashims" is a tautology. :p But thanks. I actually started with a Ruby script but then I realized this would be total overkill. – Jens Feb 22 '15 at 9:33
  • Fantastic! I've used your example to write a batch file. Since I can't write code blocks in comments, I will write my own answer. – Peter Feb 22 '15 at 21:55
  • @Peter I'm not sure this really deserves to be the accepted answer, though... assuming the method presented by StarGeek actually works (I haven't tested it) it's really the best, most portable solution. – junkyardsparkle Feb 22 '15 at 23:20

Since the best answers use non-Windows syntax, I will here post their code converted for Microsoft Windows.

@StarGeek solution, very fast and simple:

First set a base timestamp to all images:

exiftool -datetimeoriginal="2015:01:01 12:00:00" DIR

(DIR is the name of the folder containing all images.)

Then assign incremental timestamps:

exiftool "-datetimeoriginal+<0:0:${filesequence;$_*=3}" DIR

(In this case 3 is the number of seconds you want between each photo.)

Note the use of double quotes, this is required on Windows systems.

@junkyardsparkle solution, which was initially the only one I was able to work with:

This requires creating a batch file, because of the commands involved.

@echo off
setlocal EnableDelayedExpansion
for %%f in (*.jpg) do (
    echo %%f
    rem Get filename
    set n=%%f
    rem Extract number
    set n=!n:~6,4!
    rem Interpret as decimal
    set /a n=1!n!-10000
    rem Convert to seconds
    set /a n = n*10
    rem Assign base timestamp
    exiftool -DateTimeOriginal="2000:1:1 00:00:00" %%f
    rem Assign time increment
    exiftool -DateTimeOriginal+="00:00:!n!" %%f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.