Murphy Mac - Screencasts and Tutorials » Page 'Random Filenames for Digital Photo Frame Images'

Random Filenames for Digital Photo Frame Images


RandomMany of the digital photo frames on the market still don’t have the ability to shuffle images and display them in random order.   A couple people I know have frames and want to mix up the photo stream a little. The first time I ran into this issue I used a Windows utility called renamer to assign random names to the image files. But what about a pure Mac solution?

There is one, and you don’t need anything other than OS X to get it done.  Skip to the screencast if you prefer – otherwise here’s what you do:

Place the files to be renamed in one folder. It’s best to have them all in one folder without subfolders. If you have images scattered inside subdirectories you’ll have to make some adjustments to these instructions.  USE A COPY OF YOUR ORIGINAL IMAGE FILES,  there’s no reason not to.

Open the Terminal from your Utilities folder in Applications. Type cd followed by a space. Then drag the folder containing the files from Finder to the Terminal window. Hit return. The Terminal prompt should update to indicate you’re now in the directory containing the images.  This folder should NOT BE THE SAME AS THE ONE YOUR ORIGINALS RESIDE IN.  Sorry for that, but it’s important.

Finally, type the following command in the Terminal:

for i in *.jpg; do mv $i $RANDOM.jpg; done

The command is case-sensitive.  If your images have names ending .JPG you’ll need to adjust the *.jpg part of the command above to use a capital JPG.

Hit return and your image files are renamed using random numbers.  Copy them to the digital photo frame and your images should cycle randomly.  Thanks to this thread at Mac Rumors Forums.

I’ve included a screencast for those not familiar with Terminal.  Be careful in the Terminal.  You can delete files accidentally and they won’t be in your Trash !  See this warning for more information.

Screencast | Permalink

12 comments to “Random Filenames for Digital Photo Frame Images”

  1. It might be advisable to use “mv -n” to avoid overwriting existing files.

  2. they cease to be random as soon as they enters the photo frame… just a different order, but still an order.

  3. @Mike –

    This is still better than nothing. Some things can only be addressed by the frame makers…

  4. Some suggestions on improving the command as I posted it:

  5. Seems a shame to have to rename your images just to get randomness out of this scenario. I would be more inclined to keep the images as they stand and find a way to move batches in and out of where they need to be in a random order.

    Don’t pretty much all image display devices have some “random” mode for playback?

  6. I’ve only used a couple of these frames, but none of them had a random / shuffle command.

    And I wouldn’t rename the copies that I keep and store, I would run this command against a copy created for this purpose. From the post:

    ” USE A COPY OF YOUR ORIGINAL IMAGE FILES, there’s no reason not to.”

  7. Thank you all for this post, even if it was years ago. I too am trying to use Terminal to do a batch (random) rename of 2300 pictures for a digital photo frame.

    I have successfully used an expanded code (pasted below) from another website to successfully do this, but I did notice that an obvious overwrite took place. The folder no longer had 2330 pictures, but 2250.

    After I had made this mistake and researched further, I noticed a comment on this post suggested to also include “mv -n” within the code so as to prevent anything from getting overwritten. For those of us who are not as comfortable creating code, would you mind re-pasting the exact code that we could paste into the terminal command once the correct (photo) directory is chosen within Terminal? That would be great.

    Below is the code I used, which DOES NOT prevent files from being overwritten as they are randomly renamed ( taken from ):

    for i in `ls *.jpg`; do mv “$i” `od -An -N2 -i /dev/random | tr -d ” “`.jpg; done

    What should the updated code be in order to no longer overwrite files as they are randomly renamed?

    Many thanks,

  8. I executed the 1st command, and it renamed only 180 of the 321 image files.

  9. The USA is BY FAR essentially the most strict, and has only allowed one
    or two binary brokers, like Nadex.

  10. thanks you rock

  11. I keep searching and using terminal seems to be the only way to do this (I still can’t believe there isn’t a built-in shuffle in Photos, Finder or iMovie). I’m trying to randomize about 700 pictures and the first time I ran this code it only did about a 3rd of my photos. I can’t get it to work on the rest…

  12. Thanks for this trategy , I will implement this, though I am too slow to process codes and understand them but following all code blogs is helping me and saving my time.

Leave a comment