Skip to content

Instantly share code, notes, and snippets.

@mreis1
Created January 15, 2015 17:03
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 mreis1/efcb2b5e96105866df61 to your computer and use it in GitHub Desktop.
Save mreis1/efcb2b5e96105866df61 to your computer and use it in GitHub Desktop.
Apple: Create text file at current folder from finder window
http://apple.stackexchange.com/questions/129699/create-a-new-txt-file-in-finder-keyboard-shortcut
Open Automator, create a Service, set the input to "no input", Drag and Drop the "Execute AppleScript" Workflow Element onto the grey space, save the workflow;
Settings -> Keyboard -> Shortcuts -> Services, Assign a Shortcut
The Shortcut may not work, if it is assigned to an Apple-Intern Shortcut already. So be creative on choosing a new one.
Add this to the script:
try
tell application "Finder" to set the this_folder ¬
to (folder of the front window) as alias
on error -- no open folder windows
set the this_folder to path to desktop folder as alias
end try
set thefilename to text returned of (display dialog ¬
"Create file named:" default answer "filename.txt")
set thefullpath to POSIX path of this_folder & thefilename
do shell script "touch \"" & thefullpath & "\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment