silly question from a newbie (AppleScript)

Joined
Feb 10, 2009
Messages
1
Reaction score
0
Points
1
Hi,
I am doing a silly applications in AppleScript that opens and saves the content of a web page:

tell application "Safari"
activate
make new document at end of documents
set URL of document 1 to "www.url.."
delay 2
get document 1
delay 10
save document 1 in "directory/name.html"
end tell
delay 10

Here comes the catch: Instead of saving name.html, it saves "directory/name.html" as a file in the root directory.

Can someone help me? I could not find the problem.

Joao:\
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
A quick test showed that Applescript is set to the root ('/') directory. Well, at least when I post a 'do shell script ' command.

You either will have to use a full path, or set the path relative to something like your home directory. If relative to your home directory, then try placing '~/' before the directory like this;
save document 1 in "~/directory/name.html"​
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top