I have thousands of jpg's and mp4's that need sorting into a directory structure which name is based on the date the picture was created. Preferably from the EXIF date as the files modified date might be off. but If getting the EXIF date is a lot of work I'm better off using the modified date


  • file1 taken 2014-06-30
  • file2 taken 2014-07-01
  • file3 taken 2014-06-30

is moved in to directories

  • /140630/file1
  • /140701/file2
  • /140630/file3

I'm using OS X Yosemite as Unix.


You can install ImageMagick and use the identify tool with -verbose, for example:

for f in *.jpg *.jpeg *.JPG *.JPEG *.mp4 *.MP4; do
  echo $f
  identify -verbose "$f"|grep exif:DateTime


    exif:DateTime: 2013:04:08 10:45:44


    exif:DateTime: 2013:11:01 22:59:27
    exif:DateTimeDigitized: 2013:10:31 23:39:55
    exif:DateTimeOriginal: 2013:10:31 23:39:55

    exif:DateTime: 2014:07:14 10:48:43
    exif:DateTimeDigitized: 2014:07:14 10:48:43
    exif:DateTimeOriginal: 2014:07:14 10:48:43

Sorry this is not a complete solution, but if you're familiar with a scripting language like bash or Python, you could easily write a script to parse this output and decide which folder to put each one in.

As you can see some files have 3 DateTime fields, some have none, so you may be left with a few that need to be handled manually, or using the file modification time as fallback.

  • 1
    Cool tips! Never knew before of the 'identify' command. That said, if using Python, it would be much faster to use the ExifRead module. – pepoluan Oct 25 '14 at 6:18

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.