Create a gist now

Instantly share code, notes, and snippets.

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