Create New Files in Finder in OS X
Because finder STILL can't do that on its own.I was looking for a way to quickly create new files in Finder in a similar fashion to the “New → Text Document” menu available in Windows Explorer, since Finder doesn’t provide any built-in way to do that.
I created the following AppleScript to accomplish that, based on code found at a helpful Super User thread on the subject:
--Based on script found at: http://superuser.com/questions/14118/easiest-way-to-create-a-new-text-file-in-a-finder-window-on-osx
tell application "Finder"
--The following line is commented out since it is buggy in Lion.
--set p to insertion location
try
set p to folder of window 1
on error
set p to desktop
end try
set f to make new file at p
if p as alias is desktop as alias then
set selection to f
else
select f
end if
activate
end tell
tell application "System Events" to keystroke return
The script creates a new file in the current Finder window (or on the Desktop if no Finder window is open), and then selects the file and activates rename mode.
I’ve set up two different ways to trigger the script:
- Through Alfred in the form of an Alfred Extension, triggered using the ‘file’ keyword.
- By compiling the script to an application and pinning it to the Finder toolbar by dragging it there. The application can also be run via Spotlight or Alfred, or a similar tool.
Now I can finally easily create new files in Finder.
If you’d like to get your hands on the application and Alfred extension without building them yourself, you can download an archive containing them.