Skip to content

Instantly share code, notes, and snippets.

@ozrabal
Created September 4, 2020 21:51
Show Gist options
  • Save ozrabal/1561cdb95f74c28d6a07159c3416f5cb to your computer and use it in GitHub Desktop.
Save ozrabal/1561cdb95f74c28d6a07159c3416f5cb to your computer and use it in GitHub Desktop.
Create new folder from selection
tell application "Finder"
set selectedFiles to selection as alias list
set containingFolder to container of item 1 of selectedFiles
set {year:yr, month:mn, day:dy} to creation date of item 1 of selectedFiles
set convertedDate to (yr & "-" & (text -2 thru -1 of ("00" & ((mn) as integer))) & "-" & (text -2 thru -1 of ("00" & ((dy) as integer)))) as string
set theFolder to (make new folder at containingFolder with properties {name:convertedDate})
repeat with i from 1 to count of selectedFiles
set thisItem to item i of selectedFiles
move thisItem to (theFolder)
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment