Put this into an Automator service.
Useful to create a Notes file in a project folder (in Finder, obviously).
on run {input, parameters}
if input = {} then
tell me to activate
display dialog "One folder, please." buttons {"OK"} default button "OK"
else if (count of input) ≠1 then
tell me to activate
display dialog "One folder, please." buttons {"OK"} default button "OK"
else
set theFolder to (item 1 of input) as alias
do shell script "mdls -name kMDItemContentType " & quoted form of (POSIX path of theFolder) -- language-independent
if result contains "public.folder" then
--perform the action
-- ask for name
tell me to activate
display dialog "Geef dit bestand een naam:" default answer "naam"
set theName to text returned of the result & ".rtf"
set theFile to (theFolder as text) & theName
set refNum to open for access file theFile with write permission
write "{\\rtf1\\ansi\\ansicpg1252\\cocoartf1038\\cocoasubrtf290
{\\fonttbl}
{\\colortbl;\\red255\\green255\\blue255;}
\\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww9000\\viewh8400\\viewkind0
}" to refNum -- header for RTF file
close refNum
tell application "Finder" to set extension hidden of (theFile as alias) to true
tell application "TextEdit"
activate
open (theFile as alias)
end tell
else
tell me to activate
display dialog "One folder, please." buttons {"OK"} default button "OK"
end if
end if
return input
end run
Caveat: don’t tinker with the content of the write command. The file will not be usable when this is changed.
When you want something else, like another default font, you can create a file in TextEdit, and edit it’s settings. Then open in TextWrangler, and copy the header into the write command.
The given header is from a Dutch system, where default paper size is A4 (216*297 mm). The result may look strange on systems with different defaults.