Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Wallace25

macrumors member
Original poster
Feb 21, 2007
41
0
I have an applescript that I can't get to work. I am openening a file with a name of "TestScript", then adding text to it. That part works fine, but then I try to have script editor save it, and it saves as untitled.

Any ideas?

Here is the script

set fileLocation to choose folder
set x to "testText"

tell application "Script Editor"

set newDoc to make new document with properties {name:"TestScript"}


set text of newDoc to x
compile newDoc
save newDoc in fileLocation
 

xUKHCx

Administrator emeritus
Jan 15, 2006
12,583
9
The Kop
bit of a nasty way of doing it, but this seems to work.

Sure there is probably a better way of doing it.


set fileLocation to choose folder
set x to "testText"
set y to "TestScript"
tell application "Script Editor"

set newDoc to make new document with properties {name:y}


set text of newDoc to x
compile newDoc
save newDoc in fileLocation
tell application "Finder"
set sav to fileLocation & "Untitled.scpt" as string as alias
set name of sav to y & ".scpt" as string
end tell
end tell
 

lancestraz

macrumors 6502a
Nov 27, 2005
898
0
RI
Use this.
Code:
set fileLocation to (((choose folder) as string) & "testScript")
set x to "testText"

tell application "Script Editor"
	set newDoc to make new document with properties {name:"TestScript"}
	set text of newDoc to x
	compile newDoc
	save newDoc in fileLocation
end tell

You can change the text "testScript" in the first line to whatever you want to save it as.
 

Wallace25

macrumors member
Original poster
Feb 21, 2007
41
0
Use this.
Code:
set fileLocation to (((choose folder) as string) & "testScript")
set x to "testText"

tell application "Script Editor"
	set newDoc to make new document with properties {name:"TestScript"}
	set text of newDoc to x
	compile newDoc
	save newDoc in fileLocation
end tell

You can change the text "testScript" in the first line to whatever you want to save it as.


Thanks works great.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.