-- prefix_suffix.applescript (* Given a selected folder in the Finder, the script will prompt for a string that is to be a Prefix, or Suffix applied to the basename of every file in the selected folder. If choosing to use this script from the AppleScript menu extra, create a new folder named Finder Items in /Users/yourname/Library/Scripts, and copy the .scpt version of this script into it. Tested: macOS 10.14.6 (18G6020), macOS 10.15.6 (19G2021) VikingOSX, 2020-09-05, Apple Support Communities, No warranties expressed or implied *) use scripting additions set source_folder to "" set prefix_or_suffix to "" tell application "Finder" if (get selection) = {} then set source_folder to (choose folder with prompt "Pick the folder containing the files to rename:" default location (path to desktop) without multiple selections allowed and invisibles) else if (get selection as alias)'s kind contains "Folder" then set source_folder to (get selection) as alias else return end if -- if (source_folder as alias)'s name ends with "Desktop:" then return repeat display dialog "Enter the prefix or suffix to use:" default answer the prefix_or_suffix buttons {"Cancel", "Prefix", "Suffix"} copy the result as list to {the button_pressed, the prefix_or_suffix} if the prefix_or_suffix is not "" then exit repeat end repeat set the item_list to (every item in folder source_folder) as alias list repeat with anItem in item_list set this_name to (anItem's name) as text set this_ext to "." & (anItem's name extension) as text set name of anItem to my set_String(this_name, this_ext, button_pressed, prefix_or_suffix) end repeat end tell return on set_String(afile, ext, btn, astr) if btn contains "Prefix" then return (astr & my basename(afile, ext) & ext) as text else return (my basename(afile, ext) & astr & ext) as text end if end set_String on basename(afile, ext) return (text 1 thru ((offset of ext in afile) - 1) of afile) as text end basename