Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Create new blank text files via contextual menu Desktop
Whenever I open TextEdit (rarely), I am dismayed to find out that when I save the file, it only gives me four choices: RTF, HTML, Word, and Word XML. But what happens when I don't care about the formatting, and all I want is plain old txt? For a while I found myself opening a blank text file on my desktop downloaded from a website and then doing File » Save As, or even opening up Terminal and typing in touch Desktop/file.txt.

Well, today I got off my lazy butt and wrote a script (two lines of code). I then put it into Automator and saved it as a plug-in in the Finder's contextual menu. Here's the script:
do shell script "touch ~/Desktop/file.txt"
do shell script "open ~/Desktop/file.txt"
What the script does is first create a file named file.txt and puts it on the desktop, then opens it in TextEdit. I suppose someone could save the script as an application and have it open on a keyboard shortcut through Butler or Quicksilver as well. Just copy the code into Script Editor or Automator in a Do Shell Script action.

[robg adds: There are third-party tools that make this process pretty simple, too. DocumentPalette and NuFile are two that come to mind.]
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[39,347 views]  

10.4: Create new blank text files via contextual menu | 14 comments | Create New Account
Click here to return to the '10.4: Create new blank text files via contextual menu' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Create new blank text files via contextual menu
Authored by: fds on Mar 28, '07 07:40:05AM

Huh? Am I missing something?

Isn't it much simpler to go to TextEdit - Preferences and set the default Format to Plain Text?

And if you do need rich text one in a while, you just use Format - Make Rich Text.



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: MurphyM on Mar 28, '07 09:53:04AM

You might see your way as simpler, but people with years or even a decade of experience right-clicking the MS Windows desktop to create new files might prefer this method.



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: DavidRavenMoon on Mar 28, '07 02:05:53PM

You don't even have to do that. Open TextEdit, and go to preferences. In there you can set the New Document preference to Plain Text.

Now whenever you launch TextEdit, it will open a plain text document. Just stick it in the Dock, and give it a click!

People really do find complicated ways to do simple things! :)

---
G4/Digital Audio/1GHz, 1 GB, Mac OS X 10.4.9 • www.david-schwab.com • www.myspace/davidschwab • www.imanicoppola.net



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: seand on Mar 28, '07 08:05:22AM
How about Daring Fireball's recent solution to this problem?

[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: dr_clive on Mar 28, '07 08:20:00AM

Or cmd/shift/T, preferably before you start typing.

Clive



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: UberFu on Mar 28, '07 12:01:16PM

Clive hit the nail on the head_

It's interesting that people will go 12 steps out of the way just to do something_ But maybe that's why they do it - because it's there and they can_

[this message was made with Plain Text]



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: lithoman on Mar 29, '07 06:22:56AM

You can change texedit's preferences to make new files plain text.also you can always toggle in between rich and plain text in the format menu



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: cawaker on Mar 28, '07 10:49:21AM

I solved this one recently by doing 2 things, I started using PathFinder as my main finder interface. they have a built in text editor that rocks.

Also I started using quicksilver to speedily launch apps, I used to launch apps the slow way of right clicking on the applications folder in the dock and that was really slow.



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: macintron on Mar 28, '07 11:32:18AM
For me the file is always opens in plain text mode. Perhaps you can do something like this. I can't test it, but you get the idea...

do shell script "touch ~/Desktop/file.txt && open ~/Desktop/file.txt"
tell application "TextEdit" to activate
tell application "System Events"
	tell process "TextEdit" to keystroke "T" using {command down, shift down}
end tell


[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: ZacharyArnold on Mar 28, '07 12:25:20PM
Here's an expanded script I wrote to mimic the new text file contextual menu behavior in Windows. Create the contextual menu as described in the original hint, but use the following for the body of the AppleScript:

on run {input, parameters}
	
	try
		tell application "Finder" to set the sourceFolder to (folder of the front window) as alias
	on error
		-- no open folder windows
		set the sourceFolder to path to desktop folder as alias
	end try
	
	set sourceFolderPath to (POSIX path of sourceFolder) as string
	set touchScript to "touch " & sourceFolderPath & "newTextFile.txt"
	set openScript to "open " & sourceFolderPath & "newTextFile.txt"
	
	do shell script touchScript
	do shell script openScript
	
	return input
end run


[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: osxpounder on Mar 29, '07 11:50:38AM

What's nice about this hint is that I can make a text file with a right-click now, though usually I'd prefer to use keystrokes, as they are easier on my tired hands. So far I've experimented with Butler, which brings it downo to these keystrokes:

CTRL-space to bring up Butler
tex to choose TextEdit
Return to confirm

If I could have one system-wide keystroke that would:
- take whatever text is selected and put it into a new text document
- if no text is selected, simply open a new, blank text document

... that would be swell.



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: DavidRavenMoon on Mar 28, '07 02:09:43PM

Just set TextEdit to make new documents in plain text! It's amazing how people will write a script before they look in the preference settings of an application!

---
G4/Digital Audio/1GHz, 1 GB, Mac OS X 10.4.9 • www.david-schwab.com • www.myspace/davidschwab • www.imanicoppola.net



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: Krook on Mar 28, '07 03:27:31PM

To make it even better than on Windows I created an Automator workflow (could probably just as easily be an Applescript).

As it is a Finder extension it is located under Automator on right click.
It first asks for a name of the textfile, then creates in the current Finder window or the desktop and then opens it up - ready for me to write and save.

...and the Plain text is just a setting as pointed out by others.



[ Reply to This | # ]
10.4: Create new blank text files via contextual menu
Authored by: mahakali on Mar 30, '07 01:08:35AM

Or keep an empty plain text file on your desktop and set it as a stationery pad from the Get Info window. All you need to do is double-click it (or command-arrowdown if you prefer).

What's still pissing me off about OS X stationery pad is that it automatically creates a copy of the pad. In previous OSes, stationery pad creates an unsaved copy of the pad that you can later decides to save into another folder with another name or simply discard without having to go to the Finder and rename/move the file around.

How about this, create a new file from clipboard:

pbpaste > ~/Desktop/untitled.txt; open -e ~/Desktop/untitled.txt

This will overwrite exsiting file that bears the same name though. But you can either combine it with OnMyCommand from abracode.com or with applescript.



[ Reply to This | # ]