Select Page

Over the years, you could say that I’ve gone through a couple phones.

I’ve had to copy & restore data from the old phone to the new phone numerous times.

As a result, my photos have become wildly disorganized. Photo dates no longer match the actual date the photo was taken, and it’s become impossible to quickly find & pull up a specific photo that I have in mind.

Instead of relying on an app (couldn’t find anything to be honest), I wrote a Python script to restore everything back to its original state.

It reads a JPG’s EXIF date and applies it to the accessed/modified file date. If a file doesn’t have valid EXIF data, it reads the date from one of three formats in the file name: YYYYMMDD_HHMMSS or YYYY-MM-DD_HHMMSS or YYYY-MM-DD_HH-MM-SS, then applies that to the file’s timestamp instead, even if the filename should include funky “(0)” or “(1)” characters, etc.

In order for this script be functional:

1. Make the script executable.

2. Install the exifread python module.

3. Install an SSH server on your phone and mount with SSHFS.

4. Go into your phone’s DCIM/Camera directory and execute (don’t forget the two backticks surrounding pwd).

For 5.5 gigs of photos & video, this took about a minute and a half to complete.

I realize this fix should probably exist as an Android app instead of a linux-based script. If this post gets adequate search volume, perhaps I’ll consider building an app-based solution.