Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created April 2, 2021 11:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OKsign/113851b8ee1a2b286b12f758c9eeefef to your computer and use it in GitHub Desktop.
Save OKsign/113851b8ee1a2b286b12f758c9eeefef to your computer and use it in GitHub Desktop.
-- 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