OS X Yosemite:

I took thousands of pictures on a trip recently, some from my iPhone, and some from my DSLR camera.

Now, the iPhone automatically gets its time and date from the local cell towers, but the DSLR stayed set with the time and date of its original configuration.

So basically now when I mix all the photos together and sort them by time and date, they are all out of order. I would like to view the photos chronologically and to do that I need to shift the date and time of all the DSLR photos by the same (time zone) offset.

So basically, I need a command line or a script that will do something like this:

if filename = DSC_*.*
then creation_date = creation_date + 5 hours

I'm asking this for OS X specifically, but I guess it would be interesting to know how to do this in Windows or Linux as well.


2 Answers 2


Here is a condensed and modified version of the script info in the link I gave you in the comments. You can save it as a plain text file, without an extension, and make it executable per info in the link, e.g. chmod +x filename. Place the script in a folder that's in your $PATH e.g.: /usr/local/bin/

This script sets both the created and modified date/time stamp on each DSC_*.* file +5 hours on the DSC_*.* files in the working directory.

In a Terminal then cd to the directory containing the DSC_*.* files and then type the name you gave to the script and press enter.

for f in DSC_*.*; do
    ts="$(GetFileInfo -d "$f")"
    e="$(date -j -f "%m/%d/%Y %H:%M:%S" "$ts" +%s)"
    nd="$(date -r $e "+%m/%d/%Y %H:%M:%S")"
    SetFile -m "$nd" "$f"
    SetFile -d "$nd" "$f"

In case the comment to the OP gets deleted the code above is based on the answer to Updating File Created Date by x number of days Mac OSX and modified to the +5 hours requested. If you only want to change the created time then comment out, placing a # in front of, or removing the SetFile -m "$nd" "$f" line.

  • If I want to go backwards in time, do I just change this line ((o=60*60*-5)) ? and a whole day forwards would just be ((o=60*60*24)) ? etc.
    – Daniel
    Commented Jul 29, 2015 at 23:42
  • No, ((o=60*60*5)) is giving the offset in seconds for 5 hours, 60 sec x 60 min x 5 hr = 18000 seconds to the o variable. 24 hours is 86400 seconds or ((o=60*60*24)) The ((e+=o)) is doing the math to adjust the difference in the seconds since epoch, the $e variable, for that of the new date/time stamp for the file. So changing the + sign in ((e+=o)) to -, e.g. ((e-=o)) subtracts the offset o seconds from the epoch e seconds. All of this is necessary to do the math to adjust the times and provide SetFile with a value for -d and -m formatted in a way it understands. Commented Jul 30, 2015 at 0:41
  • @Daniel, Have a look at Unix time as a reference and better understanding about the seconds since epoch reference. Also look at Epoch & Unix Timestamp Conversion Tools and the man pages for date, GetFileInfo and SetFile. Commented Jul 30, 2015 at 0:53
  • Well, I did it my way ((o=60*60*-5)) and it worked great! Seems like a half dozen of one or six of the other kind of situation. Thanks for the help everyone, I got the job done.
    – Daniel
    Commented Jul 30, 2015 at 1:35
  • @Daniel, Hey that's great and I'll be the first to admit that I don't always understand the math in bash although it appears to be treating the - in -5 differently then I expected although as we now see either way (shown in the comments) would have worked. Glad you were able to resolve the issue at hand. One of the best parts of helping people is learning something new in the process! :) Commented Jul 30, 2015 at 1:59

There is a great little application called shootShifter on the App Store (and maybe directly) which is designed for exactly this. It lets you graphically select photos and set up/modify both file system and EXIF dates. It worked well for me.

(I have no connection except as a user of the app.)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .