File Management:
Easy random file renaming on Mac
Sometimes you will need an easy way to rename files. In my case I need to rename files because I need to randomly display images on a tv slideshow. The files are uploaded to Dropbox and then displayed on the tv with YoDeck. There is currently no way to randomize how they are displayed so I create random letter filenames to “randomly” show the images.Method 1: Automator
For those of you who aren’t familiar with Automator, you can watch this video to learn more.- Create new Automator
- Select Run Shell Script and drag it to your main window
- Change the settings to:
- Worflow receives current: files or folders in Finder.app
- Input is: entire selection
- Image: action
- Color: black
- In the Run Shell Script the following:
- Shell: /bin/bash
- Pass input: as arguments
- Code:
#!/bin/bash # Function to generate a random string rand_string() { local length=10 local chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' local result="" for (( i=0; i<$length; i++ )); do result+=${chars:RANDOM%${#chars}:1} done echo "$result" } # Process each selected item for item in "$@"; do if [ -d "$item" ]; then # If it's a folder, process all image files inside for file in "$item"/*.*; do if [ -f "$file" ]; then ext="${file##*.}" # Extract file extension new_name="$(rand_string).$ext" mv "$file" "$item/$new_name" fi done elif [ -f "$item" ]; then # If it's a single file, rename it dir="$(dirname "$item")" ext="${item##*.}" # Extract file extension new_name="$(rand_string).$ext" mv "$item" "$dir/$new_name" fi done
- Save as something like Randomize Filenames
- To use, in Finder (or on the desktop) right click on the folder containing the files you want to rename and inside the Quick Actions menu, click on Randomize Filenames.

Method 2: Bash
- Coming Soon
Final Thoughts
Being able to randomly change filenames shouldn’t be hard and you shouldn’t have to download a full app to do it. Hopefully this will help you out just as much as it does for me!
Posted in For Photographers
Subscribe
0 Comments
Oldest