PDA

View Full Version : Saving Text Document to Desktop




thriftinkid
Apr 18, 2008, 07:10 PM
Below I have a partial script. The script creates an untitled document and adds some text to it. All I need it to do is save the document as the name "mydocument.txt" on the desktop, but the applescript dictionary seems to be leading me astray.....or maybe I just am an idot (probably true). Any help?

make new document
end if
set the text of the front document to theText
save as "mydocument.txt" in "Macintosh HD:Users:John:Desktop"
quit application "TextEdit"
end tell



Cromulent
Apr 18, 2008, 07:40 PM
The path should be /Users/John/Desktop.

lancestraz
Apr 18, 2008, 08:47 PM
Use this to save it.
save the front document in "Macintosh HD:Users:John:Desktop:myDocument.txt"

lee1210
Apr 19, 2008, 01:16 AM
because I don't know one way or the other, will the save action save in RTF or plain-text?

thriftinkid
Apr 19, 2008, 11:39 AM
because I don't know one way or the other, will the save action save in RTF or plain-text?

The adjusted script above worked to save a ".txt" file to the desktop but it still prompts me as the program quits to save or not save the untitled document that was created. I just want Text Edit to quit after is saves it under the file name I designate.

lancestraz
Apr 19, 2008, 11:39 AM
because I don't know one way or the other, will the save action save in RTF or plain-text?
save the front document in "Macintosh HD:Users:John:Desktop:myDocument.txt"
will save it as plain text.

save the front document in "Macintosh HD:Users:John:Desktop:myDocument.rtf"
Will save it as rich text.

CaptainZap
Apr 19, 2008, 11:50 AM
You should pick up a book on Applescript if you don't have one already. You've made like 15 threads on Applescript and I bet a book could help you out with lots of the problems you have.

Cromulent
Apr 19, 2008, 11:59 AM
Use this to save it.
save the front document in "Macintosh HD:Users:John:Desktop:myDocument.txt"

Ah. So Applescript uses the old Mac OS 9 and previous form for file paths then?

lancestraz
Apr 19, 2008, 12:27 PM
Ah. So Applescript uses the old Mac OS 9 and previous form for file paths then?
You can use both. By default Applescript returns values using ":" as a separator.
set theFile to (path to temporary items folder)

But you can still work with POSIX paths.
set theFile to (POSIX path of (path to temporary items folder))

thriftinkid
Apr 19, 2008, 01:48 PM
You should pick up a book on Applescript if you don't have one already. You've made like 15 threads on Applescript and I bet a book could help you out with lots of the problems you have.

Yeah, I'm going to do that. I was looking around and I saw that O'reily book. Is it any good?

thriftinkid
Apr 19, 2008, 02:29 PM
You can use both. By default Applescript returns values using ":" as a separator.
set theFile to (path to temporary items folder)

But you can still work with POSIX paths.
set theFile to (POSIX path of (path to temporary items folder))

It's not an issues of saving to RTF or TXT. Text Edit will the the document properly, bt it prompts me to save the untitled document as well when it oes to quit. I just want it to ignore or say no to saving that document.

lancestraz
Apr 19, 2008, 03:24 PM
It's not an issues of saving to RTF or TXT. Text Edit will the the document properly, bt it prompts me to save the untitled document as well when it oes to quit. I just want it to ignore or say no to saving that document.
Use this to quit TextEdit without being prompted to save anything.
quit without saving