Friday, November 23, 2012

Randomize Digital Picture Frame Photos

I just put some photos on a digital picture frame (Smartparts SPX8E) to be displayed at a funeral.  I was disappointed to find that the photos could not be randomized.  In some cases the viewer would see many of the same photos in a row.  I went through all of the settings and could not find a way to fix this.

My first thought was to write a short Python script to rename all of the files with a random name.  This seemed easy enough, but someone must've come across this issue already...

Of course, someone has created a little tool to do this.  Check out this Windows batch file from Jason Faulkner on

The script is easy to use.
  • Insert the USB stick with the photos on it.  (I copied all of the photos to a backup folder just in case.)
  • Navigate to the USB stick in a DOS window on your Windows machine.  Here is a directory listing of the F: drive, which is the USB stick:

  • Notice many of the files have consecutive names?  This is what I want to change. 
  • Copy the batch file to this location (in this case F:\).
  • Run the batch file.  Just type "randomnames" and hit enter.  This is what you should see:

  • Type OK.  Don't sweat it.  When the script has finished, do another directory listing (type 'dir'):

Great, the photos all have random names now.  I inserted the stick into the picture frame...

This didn't change the order at all!  Was it the file date that needed to be changed?

With the USB stick back in my laptop, I updated the date on all of the files.  The POSIX utility 'touch' could be used to do this.  I used a program called ZTree to update the date on all of the files to today's date.

I tried again with updated dates.  No difference.  The files were still being displayed in the original order!  Now, the only thing I could think of is that the files are being read at a very low level, meaning they are simply being read from the stick in the physical order they are stored there.  The remedy for this is simply to move all of the files to your hard drive (either by using the move command or by copying them all and then deleting them), and then copy them back to the USB stick.

You should be able to use Windows Explorer to do this.  Again, I used ZTree.  Sort by name before copying back to the USB stick, and they should be copied in a 'random' order, because the names are already randomized.

Finally, it worked!  The photos are now displayed in a random order.  A simplified version of the steps:
  1. Start with a blank USB stick.
  2. Copy all of the photos you want to display into a temp directory on your hard drive.
  3. Copy the batch file "RenameFiles.bat" into the temp folder you just created.
  4. Execute the batch file to rename all of the files randomly.
  5. Use Windows Explorer and sort all of the files by name.
  6. Copy all of the files onto the blank USB stick.
  7. Finished.
Thanks to Jason Faulkner for writing and publishing the script to randomize filenames.