Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

This question already has an answer here:

In Finder > Select a folder > Right click, we get a popup with an option to create a new folder:

enter image description here

Is there a way to add menu item New Textfile for adding a new text file?

share|improve this question

marked as duplicate by bmike Mar 20 at 11:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

up vote 5 down vote accepted

You could assign a shortcut to a script like this:

tell application "System Events" to tell process "Finder"
    value of attribute "AXFocusedWindow" is scroll area 1
end tell
tell application "Finder"
    if result is true or number of windows is 0 then
        set t to desktop
    else
        set t to target of Finder window 1
    end if
    set f to make new file at t
    if t is desktop then
        set selection to f
    else
        select f
    end if
end tell

There is a bug in 10.7 and 10.8 that affects many other scripts and Automator services like this. Finder ignores new windows when getting the insertion location and selection properties. If you open a new Finder window, select some items in it, and run tell app "Finder" to selection in AppleScript Editor, the result is the items selected in some window behind the frontmost window (or an empty list). One workaround is to move focus to another application and back, but it results in a visual glitch.

So neither of these ways of checking if the desktop is selected work reliably:

tell application "Finder"
    insertion location as alias is desktop as alias
    container of item 1 of (get selection) as alias is desktop as alias
end tell

You could also wrap the script as an Automator service, but there is another bug where the shortcuts for Automator services don't always work until you hover over the services menu from the menu bar. If the input type was set to no input, the service wouldn't show up in context menus. If it was set to folders or files, you'd have to always secondary-click some folder or file.

Related questions:

I didn't vote to close this question, because many of the solutions in the other questions are affected by either of the two bugs mentioned above. We'll likely get even more questions like this, which could then be closed as duplicates of this question.

share|improve this answer

Edit: I couldn't get the above working as a Service but then I found a dialog hiding behind everything else where Finder was asking for permission to use the accessibility features. Once I'd enabled that the answer from Lauri Ranta worked. But the one below works well and doesn't need extra permissions.

I've tried several ways, the cleanest I've found is the Automator script provided here:

http://oscargodson.com/posts/new-file-in-right-click-context-menu-for-mac.html

And available from Github here:

https://github.com/OscarGodson/New-File

share|improve this answer
    
This works great. –  Camden S. Jan 22 at 19:05
    
This works. The instructions say to open it and hit cmd + s but that did nothing for me. I'm on Mavericks and when opening it, I was prompted to either install or open. I had choose to install it in order for it to work. –  Justin Mar 7 at 21:31

I am using XtraFinder plugin for Mac OS's built in Finder. It has most of the features including create new file in finder options.

You'll love it like I do

;)

share|improve this answer

There is a little known feature of the Finder called Stationary Pad. Imagine having a pad of paper that you could "tear off" a new sheet from on your desktop. Each page in the pad could have a custom layout and pre-existing content etc, allow you to (for example) fill in a "while you were out, X called" memo.

I'm not as a Mac at present to get screenshots etc, but if you open up a text document, and then enter the details you want to be used as your template (bearing in mind a totally blank sheet is a perfectly valid template), then save it somewhere, right click and Get Info, then click the Stationary Pad tick box, then that file will subsequently behave differently from a normal file. Double clicking to open the file will actually open a copy of the file, without any filename set, as if it were a totally new document, allowing you to fill it in and save it with a name/location of your choosing. The great thing about this is that without unticking the stationary pad option, you cannot accidentally overwrite or otherwise modify the original template.

There is more info if you google, this is a brief summary with helpful commens that isn't too old.

This isn't quite right clicking on the desktop and clicking "New File", but if your template icon is on the desktop it's arguably faster (depending on if you are faster at locating an icon and double clicking, or using any white space, right clicking then choosing from a context sensitive menu...)

Alternatively, you could use a combination of one of the scripted methods shown in other answers to get them to simply open a Stationary pad file, and you can recreate the "create blank" feature nicely from any App, even ones that don't support Applescript, and the "blank" document doesn't even have to be blank, but can be a template.

share|improve this answer
    
At first glance, this doesn't work on Mavricks, does it? –  Camden S. Jan 22 at 19:05
    
Trying this on Mavericks, it doesn't work quite as advertised in this answer. It copies the file and opens that new copy right away, not bringing up an option to choose the file name before you start editing it. (and indeed, opening it which you may not want if you just want to create and name the new file.) –  foregon Mar 3 at 22:51
    
As per "Double clicking to open the file will actually open a copy of the file, without any filename set, as if it were a totally new document, allowing you to fill it in and save it with a name/location of your choosing." perhaps my wording isn't great, I'm not suggesting you get the chance to select the filename at this point, by fill in I mean't "write stuff in your document or fill in your template etc". Hope this clear things up. –  stuffe Mar 4 at 15:22
    
This is interesting to know! However for me, I need to be able to create a new text file anywhere, rarely on the Desktop :) –  RedYeti Mar 8 at 10:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.