Scripting TextEdit

Is this possible?

I want to write a script that selects all of the text in a TextEdit document that is already open; then changes the font to Times New Roman, 10 pt; then saves and closes the file.

Actually, I like one that opens all of the TextEdit files in a folder and then does the above on each one, but that’s probably asking way too much.

Thanks,
Charlie

Charlie:

This script will take a folder on your Desktop entitled Test and change the font and size of all characters in all the documents in that folder. You can substitute the name of the font for anything you want:

set doc_Path to (path to desktop as Unicode text) & "Test"
tell application "Finder" to set all_docs to every file in folder doc_Path
tell application "TextEdit"
	repeat with an_Doc in all_docs
		try
			open (an_Doc as alias)
			delay 1
			set font of every character of front document to "Lucida Calligraphy"
			set size of every character of front document to 18
			close front document saving yes
		end try
	end repeat
end tell

It should not choke on a file TextEdit does not recognize. Be advised that any bold, italics, underlines, etc., will be lost.

I hope this helps, post back if you have any difficulties.

Thanks Craig. It worked as predicted.