Skip to content

Instantly share code, notes, and snippets.

@itod
Last active November 21, 2016 03:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save itod/3581346 to your computer and use it in GitHub Desktop.
Save itod/3581346 to your computer and use it in GitHub Desktop.
AppleScript to remove a common prefix from the name of all files in a given folder.
set path_ to (get path to desktop as string) & "FOLDER NAME HERE"
set prefix_ to "PREFIX HERE"
tell application "Finder"
set dir_ to folder path_
set files_ to items of dir_ whose name of it starts with prefix_
set start_ to (get length of prefix_) + 1
repeat with file_ in files_
set oldname_ to name of file_
set end_ to length of oldname_
set newname_ to (get characters start_ thru end_ of oldname_ as string)
set name of file_ to newname_
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment