Skip to content

Instantly share code, notes, and snippets.

@jimmitchell
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmitchell/d58cbe8feee535d675d8 to your computer and use it in GitHub Desktop.
Save jimmitchell/d58cbe8feee535d675d8 to your computer and use it in GitHub Desktop.
AppleScript to Add Empty Files in Finder Quickly
property defaultFileName : "newFile.txt"
tell me to activate
set theFileName to text returned of (display dialog "Enter a file name:" default answer defaultFileName)
tell application "Finder"
activate
if the (count of windows) is not 0 then
set theFolder to (folder of the front window) as text
set theFolder to POSIX path of theFolder
else
set theFolder to POSIX path of (get path to desktop)
end if
set addedFile to (theFolder & theFileName)
do shell script "touch '" & addedFile & "'"
if the (count of windows) is not 0 then
set addedFile to (POSIX file addedFile) as alias
select addedFile
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment