getting text from a text file w/o using TextEdit

The one problem I am having is that the only way that I know of getting the file’s contents is by using TextEdit opening the file and doing:


set TheContents to the text of the front document

Is there a better way i could do this? Like something behind the scenes. not having text edit open then quit. i thought of using a shells cript command but then i dont know how i would convert an applescript path to something the shell would likie on the fly.

This should work but if the file content is not plain text, the result might be rather ugly.

set TheContents to read file “path:to:file”

– Rob

Rather ugly? like garbled text or a crash.

cause if its garbled text it might be inretesting to see if i could poke around a bit.

If you read a file that contains formatted text (bold, italics, etc.), such as a RTF file, you will get the text and the formatting info. Under normal circumstances, I doubt that a crash will occur due to reading a file. :slight_smile:

– Rob