Last active

AppleScript to remove a common prefix from the name of all files in a given folder.

  • Download Gist
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.