AppleScript to Make Filenames Unique

424

5

Posted

Introduction: AppleScript to Make Filenames Unique

I needed this when I import photos from several sources and they have overlapping names. Simply select all the files and execute this script, probably from the User Scripts Folder.

Step 1: Add the AppleScript Icon to the OSX Menu Bar

Inside the AppleScript editor (in your OSX Applications - Utilities) go to Preferences - General and check

[x] Show Script menu in menu bar

Step 2: Add This Script to Your User Scripts

# AppleScript (multi) rename script for Finder files.
# Hens Zimmerman, October 16, 2011. # Iterate through all files and rename them. tell application "Finder" set filenames to selection set theCount to number of items in filenames repeat with idx from 1 to theCount set theFile to (item idx of filenames as text) set TheName to name of (theFile as alias) set UUID to do shell script "uuidgen" set NewName to (UUID & " " & TheName) set name of file theFile to NewName end repeat end tell

Step 3:

Now in the OSX Finder, simply select the files you want to give a unique filename and execute the script.

Share

    Recommendations

    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Microcontroller Contest

      Microcontroller Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments