Sorting Photos on iPhone, iPad and iPod

Photos App Icons

Synopsis: Trying to get photos to sort properly on an iPhone, iPad or iPod has been an exercise in futility for years. I have finally “cracked the code” and forced my iPhone and iPad to sort photos properly. This post tells the story and presents the solution: EXIFTool. Although this post will definitely be of interest to vintage Mac users, it will also be of interest to anyone who is running iTunes on any generation of Mac, and who is frustrated by the maddeningly incomprehensible sorting of photos on their iPhone, IPad or iPod. I suspect that this post is equally applicable to iTunes users on Windows, but as I am not one of those, I cannot comment in any meaningful way.

I have been an enthusiastic amateur photographer ever since my dad gave me my first camera, a Mamiya 500TL 35mm SLR, back in 1971. I was a teenager at the time, and I have been snapping photos ever since. Along the journey from that distant past to the present day, I spent the outrageous sum of money that Adobe demands and acquired a legal copy of Photoshop, with which I have become quite proficient over the years. I have invested in high density scanners, photo quality printers, numerous other cameras and of course, lenses. In short, I take photography seriously.


I acquired a new photographic instrument in 2007, even if I didn’t think about it that way at the time. Steve Jobs delighted the world with the first iPhone on January 9th 2007 (a short 8 years ago, if you can believe that!). Among its many features was a 2Mp camera, and plenty of memory to hold as many photos as you wanted to take and store on your shiny new device. In addition to photos taken with the iPhone itself, iTunes also allowed users to sync photos from their computer onto their iPhone as well. This enabled people like me to sync their entire digital photo library onto their iPhone. Suddenly, I could carry every picture I had ever taken with me, and bore people with them at will… and I did! 🙂

iPhone, 1st Generation

“every picture I had ever taken”… that was a LOT of pictures! Being the organized type, I had long since established a simple and easy to use folder hierarchy for my digital photo library. I had a folder for each year (folders were named “2001”, “2002”, “2003” and the like), and within each folder, each photo was titled with the date it was taken on, as the first part of its filename, and a short description of the photo subject as the remainder. For example, within the folder “2002” I might have had photos (files) named such things as “2002-12-25.01, The 2002 Christmas Tree.jpg”, “2002-12-31.32, Toasting the End of 2002.jpg” and so on.

The great thing about this photo naming convention was (and still is) that when viewed in almost any file manager, such as Macintosh Finder or Windows Explorer, the photos naturally sorted themselves into the correct date order. This required that you instruct the file manager to sort files alphabetically by filename of course, but since this is the general default for such interfaces anyway, it simply worked first time, every time. Hence I could easily browse through a full year of photos in simple chronological order. It was easy to use, elegant and very effective.

Alas, alone amongst all the devices I had ever put my digital photo library onto, the iPhone simply didn’t get it. Despite my elegantly simple and incredibly obvious photo naming convention, the iPhone sorted the photos within a given year’s album in an order that only it could fathom. It was gracious enough to sort the year folders themselves properly, such that the folders for each year followed each other in an orderly succession, with 2001 following 2000, 2002 following 2001 and so on, but within any given year’s folder, it seemed to be utter chaos.

Initially I thought “hey, new device, new bugs – they’ll fix this soon”… but they never did. As each new version of iTunes debuted, and as each new release of iOS rolled out, (all the way up to and including today’s iOS 8 by the way), I would eagerly check to see if this “bug” had been fixed, but I would always be disappointed. Along the way, at routine intervals, I would scan the support forums on Apple-related web sites looking for a cure to this vexing ailment. These scans made it clear to me that I was not alone. There were multitudes of perplexed users, wondering what in the name of time they had to do to get their photos to sort properly on their iPhones.


I read (and tried) all sorts of witch’s brews – tinkering with settings in iPhoto (which by the way understood and respected my ordering system with no issues at all!), changing the “created” and “accessed” dates for the photo files, lobotomizing the file names to make them simpler for iTunes to understand… the list went on and on, but NOTHING worked. My iPhone, iPad and even my iPod stubbornly continued to dance to a tune that only they seemed to hear. My photos were (dis)organized into a higgledy-piggledy mess, a situation which continued to be a real sore point for me throughout the otherwise happy years of iPhone use.

iOS 8 recently came out, and as is my wont, I took a run at solving this whole sorting debacle once again. Once again I was sorely disappointed. The situation is no better today under iOS 8 than it has been under any of its predecessors.

Recently, I read that some users believed iOS was sorting photos based on each photo’s “created” date. “OK” I thought, “lets test this idea”, and I I wrote a script to set every photo’s “created” and “accessed” dates to the same day and time, hoping that deprived of any differences in these values between files, iOS might have to fall back on some other sorting mechanism (say, what about the file name? 🙂 ). This did produce some fairly significant improvement in some year’s folders, but I had clearly not come anywhere near solving the complete problem.

iOS8 Logo

iOS 8 did however provide me with a critical piece of information that helped me finally resolve this problem once and for all. One day, whilst I was idly browsing through the photos on my iPhone, I noticed that the Photos app was displaying a date at the top of each picture. This may have been there in iOS 7 as well – I am not sure: I only noticed it after my upgrade to iOS 8. I quickly noted that for all the photos that seemed to be sorted in roughly the correct order, the date being shown at the top of the photo was the same as the filename date, but that for all the photos that seemed hopelessly out of order, the date being shown was something very strange indeed, like “31 January 1903” or some such.

This was consistent across both the properly sorted files and the improperly sorted files, and so I immediately isolated two files, one that displayed in the Photos app with the correct date shown above the photo, and one that displayed with the nonsense date shown above. I started to examine everything about each one in great detail. All I really found however was differences in the file creation and access dates, something I had tried fixing already and with only partial success.

Then it hit me. Instead of messing with the FILE’s created date, what about messing with the PHOTO’s created date? Most digital cameras embed metadata within each photo, called EXIF data. EXIF stands for “Exchangeable Image File Format”, and among the many image information tags this standard defines is one for the date and time at which the photo was taken. Each photo therefore contains within its image data information on the photo’s creation date! Ah hah! THIS had to be the missing link – the date that iTunes and iOS were using to sort the photos!


A quick check of the photos that were sorting badly showed that they did not have EXIF data, and hence no internal record of when they were created, whilst the ones that were sorting properly DID have EXIF data, and an EXIF “date and time” tag that by and large agreed with the date recorded in the photo’s filename.

A final triumph over the stubborn “iPhone photo sorting problem” suddenly seemed within reach. All I had to do was make sure that each of the file’s “created” dates were the same (and the script I mentioned above took care of that) and then set the EXIF “date and time” tag for each photo that didn’t have such a tag to the same value as the filename date. Presumably if I did these things, my photos would magically untangle themselves, and at long last my iPhone/iPad/iPod would display my photos in the correct order!

Well, that was the plan anyway. Regrettably, this was easier said than done. Even the mighty Photoshop would not allow me to edit the EXIF data in an image. If the file didn’t have an EXIF “date and time” tag already, by gosh Photoshop was not going to let me add one.


SOMEONE had to have created a tool to view and edit EXIF data, didn’t they? I turned to the web, and after searching down many a blind alley, I unearthed a tool that was so perfect I could barely believe that it existed. EXIFTool, by Phil Harvey (who hails from none other than my old alma mater, Queens University in Kingston Ontario, Canada) fully supports reading, writing and editing EXIF data. Better still, and the reason why I describe it as “so perfect”, EXIFTool will set the EXIF “date and time” tag from the image filename if asked to do so, a real bonus for me, given my longstanding photo naming convention! Finally, and best of all, EXIFTool understands bulk operations, and will do things like this on entire folders of images in a single command! It seemed perfect! Intrigued? You can get EXIFTool at

EXIFTool Camel

Why a camel as the EXIFTool icon, you may ask? The author of EXIFTool explains that EXIFTool is written in Perl, and that a camel is the generally accepted mascot of Perl … hence the use of a camel as EXIFTool’s “icon” (which a command line tool doesn’t properly have, anyway).

I could hardly believe that something as perfect as EXIFTool was available. I downloaded and installed it onto my iMac, running Mac OS X Mavericks, and pointed it at my “2014” photo folder, which seemed particularly messed up on my iPhone. I let it do its thing and then spot checked individual photos after it was done. Sure enough, all of the files that had previously not had an EXIF “date and time” tag now did, and all of the ones that had already had such a tag still had it. Nirvana! If this was the problem, I had now solved it!

Almost trembling with excitement at the prospect of finally overcoming this stubbornly intractable problem, I plugged my iPhone into my Mac and waiting impatiently for it to complete its sync. When it was done, I disconnected it, took a deep breath, and started the Photos app… SUCCESS! For the first time since I have owned an iPhone, my photos were in proper chronological order!


So, how do you do this too? Well, brace yourself folks. You will need to get just a little cozy with Terminal, the Mac OS X command line interface. EXIFTool is a command line tool and there is no friendly GUI interface for it.


Never fear, using EXIFTool is not all that difficult. Here are the steps:

    • Navigate to the folder where your photo library is. Presumably this is the folder that you have told iTunes to sync photos from for your iPhone. Assuming that it is in a folder called “MyPhotos” in your main folder, type “cd ~/MyPhotos” at the command line prompt.


    • If you have a photo folder hierarchy too, navigate to the folder of interest within “MyPhotos”. For example, if you had a folder called “2014 Christmas Pictures” inside your “MyPhotos” folder, type “cd 2014\ Christmas\ Pictures”.

      In the cd (Change Directory) command above, remember to replace each space in the folder name with a backslash and a space. The backslash tells the command line that the next space is part of the name, not the end of the name. Hence I typed “cd 2014\ Christmas\ Pictures” not “cd 2014 Christmas Pictures”.


    • Make sure that all the photos of interest have a representation of the date and time that they were taken on as the first part of their filename. This is how almost all modern digital cameras name their image files anyway, so this is probably already true, but if not, you are going to have to rename each and every file, prepending the current name with the data and time it was taken on.

      The normal format used by most digital cameras for this is yyyymmdd-hh-mm-ss, where “yyyy” is the year number, such as “2014”, “mm” is the month number, such as “12” (for December), “dd” is the day number, such as “25” (for Christmas day, as an example) and “hh”, “mm” and “ss” are the hour number, minute number and second number respectively.So, for a given photo taken on Christmas day, you might prepend the following to the file’s current name: “20141225-09-04-00-”. If the file’s original name was DSC2098746.jpg, it would now be 20141225-09-04-00-DSC2098746.jpg. You can use more dashes to make the resulting name more readable if you like. EXIFTool fully supports this. So, for example, you might feel that inserting dashes between yyyy, mm and dd makes the filename more readable. If “2014-12-25-09-04-00-DSC2098746.jpg” looks better to you, go for it. It is fully supported.

      Since I name all of my photos in this manner anyway, renaming was not an issue for me. If it is for you, and you have a lot of photos to sort, renaming every file manually may be more effort than it is worth to you. In this case, you may wish to investigate any of the dozens of good bulk file renaming tools that exist out on the web.

      Name Mangler, at , comes well recommended, and is particularly effective if you have thousands of images that need renaming. I should mention that Name Mangler is not free, and at the time of this writing, is priced at $US 19.00. I should also state for the record that I have no affiliation with Name Mangler. I have just read good things about it. By the way, one thing you don’t have to worry about is files whose names start with “DSC” or “IMG_”, but contain a representation of the date after this initial portion of the filename. EXIFTool works from the first numbers that it finds in the filename, and so it will obligingly skip over the initial “DSC” or “IMG_” filename portions.

    • Now, with every photo file in the folder (re)named with the date and time as the first part of its filename, enter the following commands at the command line prompt:

      exiftool “-datetimeoriginal<filename” *.*rm *_original

      This will process all of the image files in the folder and set their EXIF “date and time” tag from the filename of the image file.

      This will also simultaneously set the file created, accessed and modified dates to the same value. This is CRITICALLY important, as outlined above, since it appears that iTunes initial sort order is derived from the file’s “created” date. Only if this is not useful enough for sorting (for example, if all the files to be sorted have the same “created” date) does it seem to move to the apparently secondary sort key of EXIF “created” date

    • Now plug your iPhone into your computer and let iTunes sync your device.


  • After the sync is done, disconnect the iPhone. Start the Photos app on the iPhone and enjoy. You will like what you see!

    A side note here – on my iPad, following disconnection from iTunes, it took a LENGTHY period of time to finish the “resorting” of photos in the Photos app. You may need to wait a bit… don’t unplug the iPhone/iPad/iPod until it shows that it has completed syncing.

Two final notes about using EXIFTool to force iTunes to sort iPhone/iPad/iPod photos correctly:

    • You may encounter the case where all your files have EXIF data (because your digital camera properly embedded this information) and are all named properly (because you or your camera made sure of it) and STILL don’t seem to sort correctly. This is probably an artifact of the image files’ create dates. In this case, run EXIFTool on the folder of photos anyway, since it sets all of the files’ created and accessed dates to the date and time of its run. Remember, iTunes’ primary sort order seems to be derived from the file’s created date. Only if that doesn’t provide enough useful information for sorting does iTunes seem to go to the EXIF created date.


  • This entire process only seems to work on JPEG files. I have empirically shown that the above does not work .PNG files at all (as should be expected – the PNG format does not support any standardized EXIF information). However, convert those .PNG files to .JPG files and everything starts to work as expected. So, you may need to do a bulk conversion from .PNG to .JPG if you have a lot of .PNG files (which I did). Photoshop’s “Image Processor” capability is a good way to do this, and I am sure that there are dozens of other tools that will do the same.

That’s it! BTW, EXIFTool is not the ONLY editing program for EXIF data that is out there, but it is the first one I found that included all of the key functionality that I needed (edit EXIF data, set EXIF data from filename and process complete folders of photos in a single bulk operation). If you try any of the other EXIF editors out there and achieve success with them, I would be grateful if you would let us all know by commenting back on this post.

Now you may legitimately ask how it is that photos come into our possession without EXIF data. Since almost every camera inserts EXIF information into their image files, how can images NOT have EXIF information? I can provide no definitive answer to this question, but I can provide an empirical one. Empirically I have observed that the pictures I take myself with my own cameras all have proper EXIF information embedded in them. On the other hand, all the pictures that I save from social media (Facebook, Instagram and the like), and the pictures that people send me via email, IM, WhatsApp and so on generally do NOT have EXIF information. It is almost as if these mechanisms are stripping the EXIF information out of the image as part of their processing of it. This is purely a subjective observation, but it seems fairly consistent in my experience.

At any rate, no matter what the reason, EXIF information seems to go missing far too often in day to day life, leading to some pretty oddball sorting behavior on iDevices (iPhone, iPad, iPod).

So, if you are one of those people who have been suffering from the apparently random way photos are sorted on iDevices, go to the above URL, download EXIFTool, install it, and start to enjoy your photos the way you have always wanted to enjoy them! On behalf of all of us, I would like to say a huge “thank you” to Phil Harvey for his excellent tool! Thank You Phil!

Queens Logo

7 thoughts on “Sorting Photos on iPhone, iPad and iPod

  1. Pingback: Digital Photography Workflow on a Power Macintosh 7300/200 | Quadras, Cubes and G5s

  2. Found your article when I decided to get serious about the scrambling of photos on my ios devices. Excellent info. The new file naming convention turns out to be very useful. My other big problem was how to deal with files from multiple cameras. When I go on a trip I might use two or three bodies and an iphone. By naming the files with the create date I can have all the photos in the correct time sequence.
    The “-c” option handles continuous shooting files that can have the same create date by adding a copy number to the filename. Thanks again for the great article.

  3. Found your article when I decided to get serious about the scrambling of photos on my ios devces. Excellent info. The new file naming convention turns out to be very useful. My other big problem was how to deal with files from multiple cameras. When I go on a trip I might use two or three bodies and an iphone. By naming the files with the create date I can have all the photos in the correct time seqencee.
    The “-c” option handles continuous shooting files that can have the same create date by adding a copy number to the filename. Thanks again for the great article.

  4. I just wrote a longer reply which seems to have disappeared into the ether, but the short version is PLEASE WRITE AN APP to do all of the above! It’s too hard for me, and I have 27 000 scrambled photos due to a recent sync between my iPad and iMac, via iTunes.

  5. DOS copy into a folder in the order you want. For me it’s the filename, and then iTunes loads to the phone perfectly. Other copy programs “batch” copy, but DOS copies one by one in filename order, although you can copy in other sequences with batch files or other DOS tools. A simple perfect solution.

    • Hi, this sounds perfectly simple! To be very clear, you are running Windows, open a command line window (cmd.exe) and do the copy that way? If this is not the case, can you provide the full details? Thanks, Michael.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s