(* New Text File Here was created by Jonas Wisser (http://wisser.me). This script creates a new text file with a user-chosen name and opens it in the user's default .txt application. New Text File Here History: 08 July 2010: Version 2.3.1 fixes some typos. 08 July 2010: Version 2.3 includes updated information. 16 January 2010: Version 2.2 returns the dock icon to avoid a scenario in which the Filename dialog appears behind other applications. 16 January 2010: Version 2.1 adds a Cancel button and support for some odd filenames. 16 January 2010: Version 2.0, based on code contributed by perlhacker from the Lifehacker comment threads at http://j.mp/6ju0t8 7 January 2010: Version 1.0, adapted from Open Terminal Here toolbar script by Marc Liyanage *) 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 "Please enter a 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 & ".txt" set currentFile to POSIX path of currentFolder & newfilename do shell script "touch \"" & currentFile & "\"" --do shell script "open \"" & currentFile & "\"" tell application "Finder" to select item newfilename of folder currentFolder