Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

11 Answers

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.

share|improve this answer
TextMate is a much nicer editor in general over TextEdit, and well worth the price. – jtimberman Jul 28 '09 at 2:29
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 Aug 22 '09 at 4:01
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? – MattDiPasquale Feb 23 '11 at 18:20
Hmm... I found something promising: Applescript Documentation – MattDiPasquale Feb 23 '11 at 18:35

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'

share|improve this answer
8  
This is unfortunately not compatible with Snow Leopard. – Casebash Sep 25 '10 at 10:38

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.

share|improve this answer

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.

share|improve this answer

I've assigned this AppleScript to ⌃N in FastScripts. The second line is commented out because there's a bug on 10.7 where the insertion location and selection properties occasionally refer to older values for them.

tell application "Finder"
    --set p to insertion location
    try
        set p to folder of window 1
    on error
        set p to desktop
    end try
    set answer to text returned of (display dialog "" default answer "Untitled.txt")
    if answer is "" then return
    set f to make new file at p with properties {name:answer}
    if p as alias is desktop as alias then
        set selection to f
    else
        select f
    end if
end tell
share|improve this answer

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.

share|improve this answer
cool, that sounds like just about the right approach. – Jason S Dec 2 '11 at 0:44

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.

share|improve this answer

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

share|improve this answer

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
share|improve this answer
The last lines should also be quoted properly (do shell script "touch " & quoted form of currentFile instead of do shell script "touch \"" & currentFile & "\"") – Lauri Ranta Nov 25 '11 at 13:14
@Lri Thanks, you're right. Updated. – slhck Nov 25 '11 at 13:26

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.

share|improve this answer

You can create a new context menu entry.

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

share|improve this answer
1  
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 Apr 30 at 22:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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