Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- user options ----------------------------------------------
set file_name to "untitled"
set file_name_with_current_date_time to "on" -- "on" or "off
set extension to ".txt"
-- end of user options ---------------------------------------
tell application "Finder"
activate
delay 0.6
end tell
if file_name_with_current_date_time is "on" then
set DT to do shell script "date +%Y-%m-%d_%H.%M.%S"
tell application "Finder" to make new file at (the target of the front window) as alias with properties {name:file_name & " " & DT & extension}
delay 0.7
else
tell application "Finder" to make new file at (the target of the front window) as alias with properties {name:file_name & extension}
delay 0.7
end if
tell application "Finder"
sort (get files of (the target of the front window)) by modification date
set theFile to (last item of result) as alias
open theFile
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment