Function: used by defaultTexteditProgram) Create a new text document in the current directory.
Process:
Enable Automator
Select ---- Service
Select ---- Utility
Drag ---- run the apple script to the right panel
Then, replace the panel content with the following:
(* -- Author: libok Zhou (libk.8800.org, libkhorse@gmail.com ). feel free to contact me if you have questions about this script -- Usage: This script is used for Automator to add an "new text file" to the context menu, when you want to create a new text file in current folder of finder *) Tell application "Finder" tryset CurrentFolder to (folder of the front window) set currentpath to (POSIX path of (target of the front window as alias) set libkisdesktop to falseon errorset CurrentFolder to specify topset currentpath to (POSIX path of (desktop as alias )) set libkisdesktop to trueend try (* Set currentpath to (POSIX path of (target of the front window as alias) set CurrentFolder to (folder of the front window )*) set txtname to text returned of (display dialog "Please enter the text name," default answer "untitled.txt") -- If txtname is empty using "untitled.txt" as default -- no trailing extension, suffix ". TXT "-- have extension, don't touch it. if length of txtname = 0 thenset ext to "TXT" set basename to "Untitled" set txtname to "untitled.txt" elseset prevtid to text item delimiters of applescriptset text item delimiters of applescript ". "set libknameparts to text items of txtnameset text item delimiters of applescript to prevtidset Len to length of parameter Len = 1 thenset ext to" TXT "set basename to txtnameset txtname to basename &". "& extelse if Len = 2 thenset ext to last text item of libknamepartsset basename to item 1 of libknameparts as textelseset ext to last text item of libknamepartsset basename to text 1 thru-(length EXT) + 1) of txtnameend ifend if -- if the file name already exists in current folder, attach the "_ n" to the filenameset n to 1 considering casetell (get name of CurrentFolder's files) to repeat while txtname is in itset txtname to basename & "_" & N &". "& extset n to N + 1end repeatend upload newtxt to currentpath & cmdshell script" Touch "& newtxtif libkisdesktop is false then select the file txtname in currentfoldertell application" textedit "activateopen newtxtend tellend tell
Save it as "New Text Document"
You can see the "New Text Document" option in the Finder Service options later.