106

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?

5
  • 1
  • Does this answer your question? How to create a text file in a folder
    – Klesun
    Jun 8, 2021 at 14:28
  • 5
    This IS NOT A DUPLICATE! 🤦🏼‍♂️ The other question mentions that right-clicking is how it's done in Windows, but the question title does not specify that he wants to use right-clicking, and many answers—including the accepted answer—do not involve right-clicking. PLEASE STOP CLOSING QUESTIONS THAT ARE ONLY TANGENTIALLY RELATED!
    – iconoclast
    Jan 28, 2022 at 23:39
  • The question here is answered by answers in the question linked.
    – nohillside
    Jan 29, 2022 at 4:45
  • youtube.com/watch?v=sE_V0vzNTWQ
    – KcFnMi
    May 25, 2022 at 3:46

12 Answers 12

16

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.

0
24

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

;)

3
  • 1
    Good idea, but he only problem with XtraFinder is the System Integrity Protection after El Captain. You need to partial disable the SIP. Please read this url trankynam.com/xtrafinder/sip.html
    – Pedro Luz
    Feb 8, 2016 at 10:10
  • 2
    A better idea is to use BetterTouchTool, which doesn't require SIP to be disabled—it uses the Accessibility API. AND it has a "create new file in current folder" option as one of the countless actions you can trigger.
    – Wildcard
    Sep 26, 2016 at 10:19
  • There's an unlimited trial, but you can buy it Sep 24, 2021 at 11:56
16

There is a new APP in the store: https://itunes.apple.com/us/app/new-file-menu/id1064959555?ls=1&mt=12

New File Menu allows you to create new files quickly via the Finder context menu.

  • If you upgraded to macOS Sierra, you may need to reinstall New File Menu.New File Menu is simply the coolest way to create a new file on the Mac OS X platform, you can right click in any Finder window to create a new file! You can even right click on the desktop to create your files!

Important: New File Menu is implemented as a Finder extension, you need to enable "New File Menu Extension" in "System Preferences » Extensions" to make the context menu appear.

0
13

You can try New File Menu Free (the free version of New File Menu, mentioned in other answers), it's free and working fine, although it only supports one extension at a time:

enter image description here

1
  • It works perfectly!
    – mahfuz
    Nov 15, 2022 at 15:46
5

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

1
  • 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, 2014 at 21:31
5

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.

4
  • At first glance, this doesn't work on Mavricks, does it?
    – Camden S.
    Jan 22, 2014 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.)
    – user46942
    Mar 3, 2014 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, 2014 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, 2014 at 10:02
5

New File Applescript with Toolbar Icon

Found this open source gem. Can either use the .App or add the Applescript manually. Will add a New File widget to the Finder toolbar.

New File Toolbar Icon

3

If you use Alfred, you can try this workflow. http://www.packal.org/workflow/create-new-file-finder-file-type-templates

Then you can type "new" in Alfred to create a new file in the current folder.

3

New File Menu.app can be configured to provide an experience familiar to Windows users if that's what you're after.

Demo

To achieve this, purchase New File Menu.app for $1.99 from the Apple App Store

Configure the General settings as seen in the image below:

General

Under Templates, rename the Text File Title to Text Document and the Prefix NewFile to New Text Document. Uncheck all other enabled templates.

Templates

2

If you download and install BetterTouchTool you can set up this action easily; it's one of the built-in available triggers.

Better yet, you can set it up for any keyboard shortcut or trackpad gesture you like. (Including a lot of trackpad gestures you didn't know existed.)

(I'm not affiliated with BTT in any way, but I do feel that a lot more Mac users should be using it. It is the first application I install on any new Mac and I've been using it for over five years.)

0
1

High Sierra: Go to System Prefs/Keyboard/Shortcuts, choose SERVICES and check "Open Selection in a TextEdit window". It will show up in your Services menu now. You can add a hotkey there too.

1
  • How is this different than any of the other posts mentioning that App?
    – Allan
    Aug 4, 2020 at 18:10
1

This also works pretty well if you're willing to spend a bit of money: https://langui.net/new-file-menu/

1
  • Welcome to Ask Different! We're trying to find the best answers and those answers will provide info as to why they're the best. Explain why you think the software you recommended is better than others out there. Providing links is good but answers need to be self-contained and not just be a link. See How to Answer on how to provide a quality answer. - From Review
    – fsb
    Jul 11, 2018 at 20:07

Not the answer you're looking for? Browse other questions tagged .