Making a text file in Applescript

hypertron

Registered
Sorry guys, but i have yet another applescript nuisance.
How do you make a text file in AppleScript with the text that you specify in it? I would like this to happen without textedit, or any other text editing program opening, is that possible?

Thanks
-Hypertron
 
Code:
set the_file to (((path to desktop) as string) & "test.txt") as file specification

set the_data to "Hey there" as string

try
   open for access the_file with write permission
   set eof of the_file to 0
   write (the_data) to the_file starting at eof
   close access the_file
on error
   try
       close access the_file
   end try
end try

set read_data to read the_file

Slightly edited from http://bbs.applescript.net/viewtopic.php?id=11386


Alternatively, you could do a shell script which does this through the '>' option, I'd guess.
 
Back
Top