Easiest way to create a new text file in a Finder window on OSX

55

18

OK, so if I'm browsing directories in OS X Finder, what's the easiest way to create a new text file?

Right now I have to either open TextEdit, click around until I get to the same directory I'm in, or I have to open a terminal window, cd to the directory, and touch blahblah.txt. I'm spoiled by the right-click menu in Windows.

Jason S

Posted 2009-07-28T01:14:13.200

Reputation: 5 983

Answers

24

Personally I use the Open in textmate button that I have added to the toolbar. Steps to download and install the extension are in the link.

Or you can use this apple script

tell application "Finder" to make new file at (the target of the front window) as alias

Open script editor, save as an applescript application to a known location I use /Applications/Scripts and then drag it to the toolbar.

This will create a text file untitled in the current folder.

Bruce McLeod

Posted 2009-07-28T01:14:13.200

Reputation: 5 490

TextMate is a much nicer editor in general over TextEdit, and well worth the price. – jtimberman – 2009-07-28T02:29:55.377

1@Andrei: you first have to holde CMD-ALT and then select and drag the file. – user375251 – 2017-02-25T11:05:08.020

Sweet, that works. What can I add to the script so that it automatically goes into rename mode, i.e., as if I had right-clicked the new file and selected Rename? Also, how can I learn about Apple Scripting? – ma11hew28 – 2011-02-23T18:20:20.900

Hmm... I found something promising: Applescript Documentation

– ma11hew28 – 2011-02-23T18:35:29.177

Wow!!! this is awesome... Combining the apple script you've provided with "Google QuickSearch Box" I was able to create the script name it newFile and then, at any point folder I in, just type cmd+cmd newF <enter> – OscarRyz – 2009-08-22T04:01:00.050

1Could you please be more specific with "drag it to the toolbar". Maybe it's just that it doesn't work anymore in Mavericks, but I can't drag and drop the script. PS: file extension for Applescript is .Applescript or .scpt – Andrei – 2013-11-14T10:10:16.200

4You need to hold down Option+Command to drag applications to the toolbar in Mavericks. – redfood – 2013-12-19T19:47:25.493

1url is broken... – Houman – 2013-12-27T11:30:24.073

8

Adding the Touch Here App to Finder may help, but I've never used it.

Add this tiny AppleScript app to your finder toolbar and whenever you click on it it will prompt you for a file name and will create an empty file in the current folder.

Arjan

Posted 2009-07-28T01:14:13.200

Reputation: 29 084

This is the best solution: one click with prompt. – ling – 2016-10-14T17:39:35.743

7

Nufile does exactly what you want - right click contextual menu for file creation in finder. You can create most any type of file, define template files etc.

alt text

The image is for Tiger, in Leopard the 'New file' is a sub-menu of 'More'

redacted

Posted 2009-07-28T01:14:13.200

Reputation: 2 400

Link is Dead :( – cmroanirgo – 2014-07-21T04:36:25.703

1NuFile has been discontinued – Linkmichiel – 2015-04-17T07:46:24.747

9

This is unfortunately not compatible with Snow Leopard.

– Casebash – 2010-09-25T10:38:31.927

7

NOTE: After the introduction of SIP, this app does not work unless you disable it. Read more on how to do it, but it is ill-advised.


Try XtraFinder.

This app is just great, solved all my basic needs after switching from a windows platform like adding "New File" in context menu and finder toolbar, etc. Some of the features as listed on their website are -

XtraFinder add Tabs and features to Mac Finder.

• Tabs & Dual Panel.

• Arrange folders on top.

• Cut & Paste.

• Global hotkeys.

• "Copy Path", "Show Hidden Items", "Hide Desktop", "Refresh", "New File", "Copy to", "Move to", "New Terminal Here", "Make Symbolic Link", "Contents", "Attributes", … .

• Legacy label for OSX 10.9 & 10.10. Light text on dark background. Transparent window.

• Colorful icons in Sidebar.

• Size of selected items in Status Bar.

• Automatically adjust width of columns.

• Press Enter or Return to open selection.

• Display folder item count in List view.

• Middle-click to open folder in new window or new tab.

• Much more.

I use this app with OS X 10.9.5 and did not encounter any issues with it. It has native os x icon style which looks good on retina screens also. Here is a screenshot of my finder toolbar -

Finder Toolbar

Ps. this app is also free!

Rahul Thakur

Posted 2009-07-28T01:14:13.200

Reputation: 342

1Glad it helped :) – Rahul Thakur – 2014-11-15T03:23:30.873

1Doesn't work on 10.11 – Tim – 2016-02-26T13:44:36.410

@TimCastelijns It does, you have to disable the System Integrity Protection though. You can find the instructions on the app's website. – Rahul Thakur – 2016-02-26T14:18:10.963

@RahulThakur Yeah I saw, but I'm not going to do that.. – Tim – 2016-02-26T14:21:59.663

@TimCastelijns which does not mean it's not working. – Rahul Thakur – 2016-02-26T14:25:08.267

@RahulThakur true. But it's unreasonable to expect one to turn off SIP. Even the guy on the app's website says he advises against it – Tim – 2016-02-26T14:28:16.867

@TimCastelijns yes, true. Since this is a security issue and it was introduced for helping the general consumer, it is advised you should not turn it off. Then again, because of the restriction this app will not be able to provide the features. So it comes down to you what you wish to do. – Rahul Thakur – 2016-02-26T18:28:27.383

Doesn't work on macOS. Useless app. – Dirk Strauss – 2017-03-16T14:51:44.577

@DirkStrauss http://www.trankynam.com/xtrafinder/sip.html

– Rahul Thakur – 2017-03-22T08:29:58.533

5

With Quicksilver you could just:

  • Invoke QS "command x"
  • hit the "." key for text entry and add in your text
  • tab over and "cr" for create file
  • tab over and "tex" for text edit

screenie

That's how I do it. You could use the save dialog box to choose your directory or you can just drag the file directly from quicksilver into your directory.

Bryan Schuetz

Posted 2009-07-28T01:14:13.200

Reputation: 1 494

I use this method, but to create a text file in the finder directory selected, instead of opening TextEdit, I hit cmd+g. This will select the directory. So: .write some text TAB cre TAB cmd+g RETURN – audub – 2014-02-11T11:05:00.620

4

Another option is to assign a shortcut to a script like this:

tell application "Finder"
    set selection to make new file at (get insertion location)
end tell

Lri

Posted 2009-07-28T01:14:13.200

Reputation: 34 501

3

If you use the command line for other purposes as well, you might like DTerm. It provides a pop-up command line whose current directory corresponds to the frontmost window (works with any window which has an icon in the title bar), so you can just press the shortcut and type touch blahblah.txt without needing to change directories.

enter image description here

There are Windows-style contextual menu file creators which are a more direct answer for your problem. But if you are a frequent command line user — if you're the sort who has a project open in an editor and a corresponding terminal window — then DTerm is well worth trying as a broader tool.

Kevin Reid

Posted 2009-07-28T01:14:13.200

Reputation: 2 854

cool, that sounds like just about the right approach. – Jason S – 2011-12-02T00:44:02.827

2

The AppleScript-based application NewTextFileHere does that, too. Download page is here. It can be dragged to the Finder toolbar, and it can open the file automatically once it's created.

If you open the application package …

enter image description here

… and go to Contents/Resources/Scripts/, you can open main.scpt and edit it. For example, I was annoyed that it only created text files. Change it to the following to just have it create any file you want:

try
    tell application "Finder" to set the currentFolder to (folder of the front window as alias)
on error
    set the currentFolder to path to desktop folder as alias
end try

set newfilename to ""
(*repeat while newfilename = ""*)
display dialog "Filename?" default answer newfilename buttons {"Cancel", "OK"} default button 2
set newfilename to text returned of the result
(*end repeat*)
set currentFile to POSIX path of currentFolder & newfilename

do shell script "touch " & quoted form of currentFile
do shell script "open " & quoted form of currentFile

slhck

Posted 2009-07-28T01:14:13.200

Reputation: 182 472

1

I usually start a text file in my editor (TextMate), save the file when the "Save" dialog appears switch to the Finder and drag the folder (Click and hold the folder itself or the folder icon in the title of the window) and drag it to the open "Save" panel. The Save panel will then switch to saving in that directory.

If you have Default Folder it's even easier. Just click on the folder's window without switching to the finder and you are then saving in that folder.

Mark Thalman

Posted 2009-07-28T01:14:13.200

Reputation: 990

1

You could replace Finder with Path Finder.

Path Finder offers the tools you need to access and manage your files quickly, accurately, and completely on OS X. A world-class operating system deserves a world-class file manager. Dive into a familiar interface packed with uncommonly powerful features and make your file system sing with Path Finder 6.

user151019

Posted 2009-07-28T01:14:13.200

Reputation: 5 312

1

If you also use an application launcher, it's no big deal.

Personally I use AlfredApp and I can do like this

> touch ~/my_text_file.txt

the '>' will tell AlfredApp to execute the following command.

enter image description here

Tuan Anh Tran

Posted 2009-07-28T01:14:13.200

Reputation: 444

1

With a button on the Finder toolbar:

enter image description here

Steps to create the button:

  1. Create a new applescript using the AppleScript Editor provided in Applications/Utilities

  2. Paste tell application "Finder" to make new file at (the target of the front window) as alias and export as an application.

  3. Drag to finder (In Mavericks to create a shortcut you must hold cmd + alt while dragging)

Instructions to create the icons are here.

xyz

Posted 2009-07-28T01:14:13.200

Reputation: 141

1

If you want to just create a file you can directly use this command in the terminal, touch Filename.extension

If you want to create a file with context inside, you use this command.

echo "This is my sentence inside the text" > Filename.extension

Notice the trick here, is you are actually using the echo to print/post whatever is in-front of the echo command and right after you just say oh why don't you put this echo in this Filename.extension instead of echo it to me on the screen.

amrx

Posted 2009-07-28T01:14:13.200

Reputation: 137

1

This has also been discussed on Apple SE. I currently use the drag and drop solution. This has the benefit whereby you can have a large number of template files. So addition to have a blank textfile, you could also have other common blank files that you might use (e.g., Excel, Word, LaTeX templates, etc.)

The answer is here, which I quote below:

A simple drag-and-drop solution works for me.

Create a folder called "New documents". In this folder, save a blank document of each type you want. In my case, I have a blank TextEdit document (.rtf) and a blank TextMate document (.txt).

Lock this folder (select, cmd-I, click 'Locked').

Put the folder in the Dock.

Now, whenever you want a new document, you simply drag it from this Dock folder to wherever you want it. Because the "New documents" folder is locked, the original won't be deleted; rather, the Mac will make a copy for you.

Jeromy Anglim

Posted 2009-07-28T01:14:13.200

Reputation: 642

0

Neu does exactly that http://www.elegantchaos.com/neu/ – it adds "Create document" item to "Right click -> Services"

artnikpro

Posted 2009-07-28T01:14:13.200

Reputation: 101

0

You can create a new context menu entry.

Here is a guide: http://www.hongkiat.com/blog/customize-mac-right-click-menu/

Here is the summary:

  1. Create a service with Automator, that takes Files and Folders as input, and applies to Finder application. The trick here is to make the automator that creates a blank file.
  2. Save the service. It will be saved in ~/Library/Services. But the useful thing to know is that it will also appear in the context menu of the files and folders, under the submenu "Services".
  3. Optionally, create a keyboard shortcut. Go to System preferences -> Keyboard -> Shortcuts -> Services and find your automator service there, assign a shortcut key that you like.

Alex

Posted 2009-07-28T01:14:13.200

Reputation: 1

2

Welcome to Super User! Generally we like answers on the site to be able to stand on their own - Links are great, but if that link ever breaks the answer should have enough information to still be helpful. Please consider editing your answer to include more detail. See the FAQ for more info.

– slm – 2013-04-30T22:55:04.217

0

This script will add an item to your context menu (tested on OSX Mavericks) and is VERY easy to install:

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

To install on Mavericks:

  1. download the script
  2. Open New File.workflow
  3. I was prompted to either install or open -- choose to install.

That's it.

You'll see the 'New File' option when you right click the parent folder or any file. Sometimes it is under 'Services' menu item.

Justin

Posted 2009-07-28T01:14:13.200

Reputation: 205