Skip to content

Instantly share code, notes, and snippets.

@hackingbutlegal
Created February 11, 2013 02:17
Show Gist options
  • Save hackingbutlegal/4752007 to your computer and use it in GitHub Desktop.
Save hackingbutlegal/4752007 to your computer and use it in GitHub Desktop.
AppleScript to run through a folder, and for any loose files, create a folder for each and name it same as the file. Paste into AppleScript editor, highlight folder in Finder, and click 'Run'.
tell application "Finder"
set selected to selection
set current_folder to item 1 of selected
set mlist to every file of current_folder
repeat with this_file in mlist
set cur_ext to name extension of this_file
set new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)
set new_folder to make new folder with properties {name:new_name} at current_folder
move this_file to new_folder
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment