41

I want to specify a directory and have the software find all the photos in the directory and its sub-directories, and if they contain EXIF date/time, it sets their filesystem timestamp to match the EXIF.

11 Answers 11

47

This is the inverse of Is there any software which will set the EXIF Dates based on the file's modification date?, and I'm sure all of the programs listed there will apply.

jhead

Of these, for this very simple task, jhead is my suggestion. For example, the command

jhead -ft *.jpg

sets a bunch of files so that the file timestamp matches EXIF.

jhead with find, for going through subdirectories

In order to perform recursion into subdirectories, you could to combine it with the find command available on Linux/Unix/Mac (or Cygwin for Windows):

find . -name '*.jpg' -exec jhead -ft {} +

Or to find any of *.JPG *.JPEG *.jpg *.jpeg ... you can also try

find . -iname '*.jp*g' -exec jhead -ft {} +

You can also use find to just show all the files that would be... found, without executing any other command (like jhead):

find . -iname '*.jp*g'

Other Tools

Other utilities like ExifTool or Exiv2 are much more capable, but at the price of complexity. I can never remember offhand the right options to do anything with those and have to look at the documentation every time, but jhead -ft is easy to remember with the mnemonic "fix time".

ExifTool

Just for completeness, though, I did look at the documentation, and with ExifTool, do this:

exiftool -r '-DateTimeOriginal>FileModifyDate' directoryname

(Remove the -r if you don't want recursion, and if you do that, you can also give a list of files or a wildcard instead of directoryname.) And be careful with those quotes — if you're running this on Windows, you want " instead of '.

Exiv2

With Exiv2:

exiv2 -T rename *.jpg

Beware that with lowercase -t (or without any -T) Exiv2 will also rename the file to a new name based on the timestamp, which may be very confusing. Exiv2 also does not do recursion.

  • 2
    You are right, this is the opposite but infinitely more useful :) – Itai Sep 14 '12 at 17:11
  • jhead is very useful for this - AND for many other jpg file manipulations. Be careful when using it - it is an extremely powerful tool that can wreak a certain amount of havoc if misused. I recommend using it in a batch file so you always do what you intend, and testing the result on a test file set first. – Russell McMahon Sep 14 '12 at 23:23
  • +1 but I awarded myself the answer ;-) Just so others in future can find a way to do exactly what I asked ... – Mawg says reinstate Monica Sep 19 '12 at 4:39
  • @olibre Yes, that will work on Linux/Unix or Mac. – Please Read My Profile Jan 18 '16 at 0:35
  • I have noticed some picture browsers present (diaporama) pictures only on filename order (not on file modification time). Finally I use the EXIF timestamp to set the file time AND to prefix the file name. I use command find -name '[0-9][0-9]*' -o -iname '*.jp*g' -type f -exec jhead -ft -n%Y%m%d_%H%M%S_%f {} +. Explanations: -name '[0-9][0-9]*' to prevent renaming again files already having a date prefix ('[0-9][0-9] to take into account years and months). -iname '*.jp*g' can be skipped because jhead only processes supported files (only JPEG files). %f to keep original filename. – olibre Jan 18 '16 at 23:28
13

Irfanview and jhead will both do what you want.
Both free.
Links to both below.
jhead is command line driven or can be called by other processes.
Irfanview version can be invoked from a command line or internally in a batch or on a file by file basis.

Example below for Irfanview shows how to copy in either direction:


Irfanview

Allows GUI or command line changes of batch or per file date/time transfer from EXIF to file spec or vice versa (with no other file changes if so desired).

Source: Free from www.irfanview.com

This is MUCH easier and quicker in practice after just a few uses than the instructions below make it appear. eg
To convert a single file's date/time to EXIF values requires
Shift-J, Alt-F, Enter.
Seeing why the 1st few times takes longer.

To do this for a batch of files SOUNDS complex to learn -
It requires: T, Ctrl-A, Alt-F, J, Enter, (Alt-F), Enter
(Or: T, Ctrl-A, Shift-J, Enter)(gives fewer options)
BUT in fact it is almost wholly intuitive after a little use - menus guide you initially until brain path forms.

GUI, per file

  Options, JPG lossless rotation  (Shift-J)
    Select "Apply original EXIF date/time to new file"
        Consider also selecting other options

enter image description here

GUI, one or many files (via Thumbnail view)

WARNING: (Added 2020!)
It's been pointed out that selecting the wrong options can get an undesired result - eg all destination files set to a single selected date and time. Doing it right is "not too hard" - but DO look at the various check boxes and decide which one suits what you wish to do.

Open Thumbnails view ('File, Thumbnails' or 'T' from Window view
Select images to change EXIF data of 
    usually all in folder -> Ctrl-A
Then: File, 'JPG lossless operations'
    (1) Change EXIF date/time
      "Change EXIF date/time"
        Options are offered to set Date/time to specific setting
        or to move all times back/forwards by selected DHMS amount 
              calculator provided to check result is as desired.                 
     (2) Transfer EXIF date / time to file saved date time
          "Lossless rotation with selected files"  [Shift-J]
          then, as for single file version above
              Select "Apply original EXIF date/time to new file"

enter image description here

From command line - this is a "rotate" with NO action except to copy date/time from EXIF to file date and time. The opposite can also be achieved if desired. :

  • i_view32.exe file_spec\*.jpg /jpg_rotate=(0,0,0,1,0,0,0,0)

  • To copy date/time in opposite direction ((filespec to EXIF)
    use as above with (0,0,1,0,0,0,0,0)


jhead

will do just about anything you can imagine with jpeg files

Source: Free from http://www.sentex.net/~mwandel/jhead/

I use a batch file as below. Other options are possible:

  • jhead -ft %1.jpg

They say: Things jhead can modify in an exif jpeg file

  • Up-right images according to rotation tag using jpegtran
    Set or relative adjust internal exif timestamps
    Fix date / time offsets in large batches of images
    Re-name or date stamp files according to exif timestamp
    Transfer exif headers between images
    Replace thumbnails inside Exif headers
    Edit jpeg comments (but not the Exif comments)
    Delete exif or comment sections from jpeg images
    Create new minimal exif header containing date and thumbnail

_________________________

Note: August 2016: "Anonymous user" correctly suggested that one suggested conversion did not work as I said. I've extensively added to the area concerned.

  • August 2016: "Anonymous user" correctly suggested that one suggested conversion did not work as I said. I've extensively added to the area concerned. – Russell McMahon Aug 27 '16 at 0:55
  • What about raw files? – Michael C Dec 15 '17 at 9:39
  • @MichaelClark I'm glad you asked that question :-). I note that we all seem to have addressed JPG files and not RAW. I'd imagine that you would be one of the more likely people to ask re how to do this with RAW files :-). – Russell McMahon Dec 15 '17 at 11:58
  • BEWARE: Step 1 under "GUI, one or many files (via Thumbnail view)" is misleading: it sets all selected files to the same date and time (which is not what was asked in the question). Only step 2 leads to the requested result. – Christoph Jan 10 at 22:18
  • @Christoph Thanks. I added a general cautionary note at the start of that section. – Russell McMahon Jan 11 at 0:16
4

Just another command line EXIF tool that can do change the last modified date of files to match the time of taking the picture, based on the EXIF metada in the JPEG image file:

 exiv2 -T rename somedir/foo*.jpg

No worries, the command argument rename is ok there and does no harm.
It's just that the file rename action is misused to only create the side effect of changing the timestamp.

2

While I really don't recommend relying on the file date/time when it comes to your images you can use a free tool called EXIF Date Changer to batch set the file dates of all your JPG images. The default setting will set both the date created and date modified file dates to the photo taken taken.

The reason why I don't recommend this is the file date is easily updated. If you edit the image the date modified gets updated. If you copy the image it gets a new date.

A much better solution is to rename the files to include the date/time in the filename itself. This still allows easy sorting and works well with images stored on iPhones / dropbox.

EXIF Date Changer - Set file dates to date taken

2

Check out my new free software "Photo Date Organizer": http://photodateorganizer.sourceforge.net/

enter image description here

  • 2
    From the SourceForge page: "Brought to you by: killdaclick". Advertising your own products isn't forbidden here, but you should make it clear what your affiliation is. – Philip Kendall Jul 15 '15 at 11:27
  • @PhilipKendall done :) – killdaclick Jul 16 '15 at 12:14
2

FastStone Image Viewer can do this (version 4.9 used) - just select the files in thumbnail pane, right click them, select "Tools" > "Change Timestamp" - then you can either use EXIF (with or without modifications) data or use wholy custom fixed manual date/time.

  • Wow! I did ,not know that.I have been using their screen capture tool for years and have not found anything better . You cna get the last free version here; I on't need any of the for pay features. I have also used their viewer in the past, but did not know that it could do that. – Mawg says reinstate Monica Aug 4 '17 at 9:53
1

Advance Renamer is the best user friendly software which is very simple.

  1. Drag and drop all the photos to AR(Advance Renamer)

  2. Click on (Top left) Add Method -> New Name

  3. Click on one of the image bottom middle you'll see a button ExifTool which shows all metadata just click on an attribute and you'll get the tag In this case it is <ExifTool:DateTimeOriginal>

  4. Copy this and paste in the New Name textbox You can add anything before or after like IMG_<ExifTool:DateTimeOriginal> , DSC_<ExifTool:DateTimeOriginal> etc.

  5. Click Start batch (Top Right) This will rename all your files with the date E.g. 2017_12_01 19_10_12 It's always good to have the original date in the file name cause attributes may be lost but file names won't.

  6. Again drag all renamed files on to AR
  7. Click New method -> Timestamp
  8. Check All 3 checkboxes Create, Modify, Accessed(Accessed sometimes may not work just uncheck it if it happens)
  9. Select FileName Pattern and paste <Year>_<Month>_<Day> <Hour>_<Min>_<Sec>
  10. Start Batch.
  11. You're good. Mission Accomplished
1

I signed up to StackExchange just so I could thank the OP for having posted this, and add my workaround bc some of the commands here didn't work for me. Sorry, I'm gonna talk about my process.

I'm in the midst of a "Let's finally clean up my photo archives" effort as the struggle is real, especially since iCloud and Google Photos take them from your device and file management has little to do with it these days (and in earlier times, good services and products were a little wayward and enforced a weird randomness and duplication that required real effort to overcome.)

I've used Flickr to get photos off my machine when my drive was too small to hold them all. I've used Google Photos on one account since 2006 so I had a set of random duplicates and unique pics up there, through its different upload incarnations.

When iPhone photography really started going, I'd connect by USB, import them to my Dropbox which would rename them with a date-time stamp 🙌🏻, put them into a year/month folder with a bit of curation to sort out screenshots and shopping photos, and Google Photos watched that archive folder to upload them. This worked well until iCloud seized the photos from my iPhone and getting them proved to require its own workflow.

Because duplication has always been a BIG problem, a tool called Gemini II finally made this clean-up and archive project possible.

To consolidate my archive on an external drive, I decided to download all pics but the most recent off iCloud (using Image Capture and a USB to my phone: not 100% reliable), Flickr, and Google, and clean it all up.

That's how I discovered Exif data: some photos (only some) weren't flat files (see image below) and showed their metadata in the Finder. Most only have the Created-Modified date visible. What I downloaded from Flickr (and some from Google) saved as if they were created and modified on the day I downloaded them. Not good. Some had visible EXIF data, but many/most looked flat. I had been deleting duplicates bc they had the wrong timestamp (if they were same size or smaller, that is). Finding out about Exif data and time stamp led me here.

The Dropbox step has always been important to me because IMG_#### or DSC#### has always been useless. Someone asked me why I didn't skip the Dropbox step and use Automater to rename them. Automater doesn't have the capability that I can see, but thanks to Jhead this is finally going to work.

I figured out how to first install jhead and then run jhead through a directory recursively and more often than not, EXIF data was still in the photo files. Result: jhead changed the dates of the files to what was in the EXIF data. No disappointments.

First, for Mac users: follow the untar installation instructions from the command line (Terminal). If you don't find them for jhead, find general untar instructions and sub in the location of the jhead tarball. This worked, because downloading and trying to install from the command line certainly didn't. Next: make sure you install Xcode off the App Store. All Apple developers need this program and it makes commands work that otherwise won't. It's needed for 'make' and 'install make'.

Using the jhead tool: I'm not familiar with reading Unix instructions and manuals (man jhead) but familiar enough with CLI that if someone has documented something somewhere, I try their options until something works.

This didn't work for me:

[directory that I want]> find -name '*.jpg' -exec jhead -ft {} +

Elsewhere on StackExchange I found a different recursive-search string that I got to work for find (it had a -print option that didn't seem necessary):

 find . | grep '.*[.]jpg' 

but if I added the jhead command, I'd get an error saying it didn't understand 'grep'

Deconstructing search terms by adding and taking away search options/variables and trying to get jhead to be a part of that command didn't work until I tried an old convention:

jhead -ft ./*/*.jpg

This ran through an entire long-ish directory and it didn't spit out very many errors like "contains no EXIF timestamp" or "Error: Time '0000:00:00 00:00:00': cannot convert to Unix time"

When I looked, only a minority of downloaded-yesterday timestamps remained. So I tested this on the other 10 folders of files I had in my "duplicates" folder. Things dated 2020 reverted to 2004, 2013, 2012. I learned that if you run through the same directory twice, you don't get output a second time.

Then I used jhead to rename my files according to the timestamp convention. It worked like a charm; if the original file name contained meaning to you and you want to retain it, make sure to include this in your chosen date-stamp string:

' '%f … *.jpg

I now find it frustrating that Finder is inconsistent at displaying this info when it could. Below is an example of a file that Finder is showing complete information for (uncommon). Image of Mac OS Finder information of photo EXIF data, complete

  • Hi, welcome to Photo-SE. This Stack Exchanges are Q&A sites, where each answer attempts to directly answer the question. They are not like more typical discussion forums, which are often threaded, and posts are replies to each other as much as (often more than) to the original post. As written, your answer is very discussion- and narrative-oriented about your needs and process for a renaming tool, rather than focusing on answering the question as asked. – scottbb Jan 18 at 16:39
  • On a technical detail, the reason find -name '*.jpg' -exec jhead -ft {} + didn't work is because find needs a path to search in before expressions like -name <...> are given. I've updated the accepted/highest voted answer to fix the error. Try this instead: find . -name '*.jpg' -exec jhead -ft {} + – scottbb Jan 18 at 16:41
  • This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – scottbb Jan 20 at 4:47
  • What makes you think I didn't start the command from within the path of the directory I wanted? If it didn't work, it didn't work. I found my workaround. It made my life easier. So I posted it and passed it on. If real-world examples that explain things to non-programmers aren't welcome, and I get scolded for not being technical enough, I won't comment again. Bravo. – janerette Jan 20 at 14:49
  • If you typed it as you wrote, then there's no way the command would work. I.e., input error. What I suggested (find . -name '*.jpg' -exec jhead -ft {} +) is what you would need to use if you wanted to run it from within the path of the directory you wanted. The dot as the path means "local directory". find requires a starting search path. This is available from find's manpages. – scottbb Jan 20 at 19:14
0

I suggested it to the author of PhotoRenamer, who replied ...

PhotoRenamer 3.2 http://www.tgmdev.be/applications/photorenamer/photorenamer.php

I add a button in the ‘Options’ tab of the Ribbon .. From there, you can select the option for updating the file time status of the file ..

By the way, to avoid the use of mask, I also add a new mask attribute: %F. If you use this simple mask, the file is renamed ... with it’s own name ... So you are not obliged to rename the file for which you want to update the file time attributes ...

0

This is an old question and it looks like there are a few suggestions that should work well, but the one I arrived at to sort a file ordering issue after an Android phone upgrade was this.

  • Crank open Windows (for the first time in ages)
  • Install ExtFS or something that can read ext4 partitions
  • Copy photos to hard disk from Micro SD
  • Use Attribute Changer (https://www.petges.lu/home/) to set created/modified dates to the EXIF date
  • Whack card back in phone
  • Copy photos back to phone over MTP

Maybe this will be useful to someone.

-2

The other free program is Google Picasa - you can easyly batch change date and time for all the photos:

enter image description here

enter image description here

Nice article about it: How to Change a Photo’s Date in Picasa to When the Photo Was Taken

  • 2
    How is this solution working ? The OP wants to change the file date to correspond to the EXIF date. That is probably not what Picasa is doing. – Olivier Jun 7 '16 at 10:17

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.