Terminal Tips: Generate random filenames for digital photo frame images

Aron Trimble
A. Trimble|02.25.10

Sponsored Links

Aron Trimble
February 25th, 2010
Terminal Tips: Generate random filenames for digital photo frame images
It's not at all unlikely that you or a relative have received a digital photo frame as some sort of gift. The concept is great, one frame on your mantle, many pictures on display. Unfortunately, Apple has yet to enter the photo frame market -- at least until the iPad is released, that is. In the interim, we are stuck dealing with photo frames that look good but do not always function as we expect.

One example of a photo frame feature gap is the lack of ability to "shuffle" photos so that they can be displayed in a random order. While sitting at my grandma's house for hours on end, it quickly became a personal challenge to try and successfully guess the next photo that would appear.

Luckily, the screencast junkies over at Murphy Mac have found a somewhat simple solution to this conundrum. The problem is the result of frames using the all-too-common alphabetical sorting method when showing photos. While this is useful for organization, it is less helpful for the purposes of the photo frame. The answer lies in assigning totally random filenames to your digital photos. As the title indicates, this is a Terminal.app-based tip so you'll have to get your hands a little dirty with this one.

The process is something that could take a long time, especially when you consider that many photo libraries have thousands of images. However, through the power of Terminal and the use of a for-loop, it is possible to randomly rename an entire folder of images with one fell swoop.

To begin, you will need to place all of your images in a single folder. We here at the TUAW HQ cannot recommend strongly enough using copied image files and triple-checking your backups prior to moving forward. Open up Terminal.app and use cd to navigate to the new directory where you placed your image copies (now might be a good time to check your backups a fourth time). When done, type the following command and then press return.

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

Assuming all of your photos are jpegs and located in same directory, then after some whizzbangery you will have a folder filled with very strangely-named images. Copy these files to your photo frame and you now have a fully randomized photo slideshow. Feel free repeat as often as your guests (or your OCD) require. Got any other handy Terminal tips? Feel free to share them in the comments!
All products recommended by Engadget are selected by our editorial team, independent of our parent company. Some of our stories include affiliate links. If you buy something through one of these links, we may earn an affiliate commission.
Popular on Engadget