Sorting pictures

December 21, 2015 by · Leave a Comment
Filed under: Photography, SmartPhones & PDAs, Technology 

I’ve been backing up my iPhone photos to my Windows 10 desktop using Microsoft’s OneDrive.  The photos are on my local drive as well as the cloud.  The downside is that all the photos, movies, and screen shots are dumped into a single directory, and there are a lot of them.

I prefer to have them sorted by date into directories.  A directory for each year, with sub-directories for each month.  I could do this by hand, but that’s a pain, and I have to remember to do it on a regular basis.  Plus I’ll probably want to do the same for my wife’s iPhone photos.  So I decided to write a python script to scan the camera roll directory, and copy the files to a directory in my photo archive section.  The scrip will create directories if needed and skip files that are already in place.

That part was pretty straight forward. I used os.chdir() to get to source directory and os.listdir() to get the directory contents.  Don’t want to create month directories for directories, just files, so I used os.path.isfile() to filter out non-files, and then check the file extension.  I only want jpg, mov, png, and tiff files.  I use Camera+ most of the time, which produces tiff files instead of jpg files. The png files are screenshots.

I used os.stat() to get the create time, and found files I exported to the camera roll from Camera plus had a create time of when they were exported, not the time the photo was taken. (Once I started having Camera+ dump straight to the camera roll, I didn’t have this problem).

So, I dug a little deeper and found I could get an image created time stamp with a getImageDate() call.  Downside was this didn’t work for png, tiff, or mov files.   So I had to do some extra sorting, and wrote another function to use on just the jpg files. I called the open() function from the Image library, and extracted the exif data using the _getexif() function. This works most of the time, so when it fails I had it return a ‘?’ rather than the time stamp string.  Seeing that caused a fall back to the getImageDate() function.

This extra call to the Image library made the placement of the files more accurate.  I had the base time function return the month as a three character string and the year as a 4 characters string.  This required some basic string manipulation. Those two parameters were added to predetermined destination and passed to a function I had written for another project that checks if directory exits, and creates it if it does not.

Next was to have the program check to see if the file already existed in the correct destination directory.  If it did, don’t bother copying it again. This will make the incremental runs faster and save on unneeded file transfers.

Now I have a functional script that I can set up to automatically run once a week.  Once the files are archived off OneDrive, I can removed them there and on the iPhone is order to free up space.

Originally posted to Urbin Technology.  I put the source code for the time stamp functions there.

Friday B-Movie Pick: The Man From U.N.C.L.E.

December 19, 2015 by · Leave a Comment
Filed under: Movies 

The Man from U.N.C.L.E.
Guy Richie shows his love for the 60’s TV series with this Cold War era movie. It’s the early 1960’s and the Cold War is running hot. The movie starts with CIA agent Napoleon Solo up against KBG agent Illya Kuryakin. Kuryakin doesn’t stop Solo from getting the daughter of a German scientist out of East Berlin, but he comes a damn closer than Solo is used to. So when they are told they have to team a few days later, there is hostility and mistrust. This is an origin story, about how the U.N.C.L.E team was formed and the enemy agents learned to work together. I enjoyed, but then as a child of the 60’s I remember seeing this show when I was very young. I saw a lot more of The Avengers and The Wild, Wild West, which are of a similar theme. Check it out, it’s a good spy story with a touch of humor.

Friday B-Movie Pick Archive

Monday Book Pick: The Martian

December 14, 2015 by · Leave a Comment
Filed under: Monday Book Pick, Science Fiction 

The Martian by Andy Weir

A fun SciFi adventure read. By adventure, I mean someone else in a huge amount of trouble, very far away from me. Quick summary, astronaut Mark Watney gets left on Mars when his team has to leave Mars in a large hurry because a really big sandstorm is about to tip over their ascent vehicle. He’s injured on the way to the ascent vehicle, knocked out with his bio monitor destroyed. So it looks like he’s dead to the rest of the team. Watney’s challenge is to survive long enough to be noticed, and then rescued. This reminded me of a Heinlein juvenile, which is a good thing. A fun and engaging read.

Monday Book Pick Archive

 

  • My Tweets

  • Feed Me!