Re: Ultra Newbie question
Re: Ultra Newbie question
- Subject: Re: Ultra Newbie question
- From: Michael Terry <email@hidden>
- Date: Mon, 1 Dec 2003 14:42:32 -0800
On Dec 1, 2003, at 1:32 PM, Lawrence Conley wrote:
I'm studying Applescript hard for the first time and am writing
scripts to
get my hands dirty and just learn by doing. I wrote the following
simple
script to create a folder on my desktop and then give it a name. The
trouble
is, I want to modify the script so that it will perform the intended
functions on ANYONE'S desktop but am having a difficult time figuring
out a
correct "set path" statement that will allow the script to create the
folder
in the CURRENT USER'S Desktop folder on anyone's machine. Any ideas?
All
feedback will be most appreciated.
tell application "Finder"
activate
make new folder at folder "Desktop" of folder "larry" of folder
"Users"
of startup disk with properties {name:"untitled folder"}
set name of folder "untitled folder" of folder "Desktop" of folder
"larry" of folder "Users" of startup disk to "My Amazing New Folder"
end tell
Luckily, Finder is happy to work with path strings and aliases, not
just Finder object references, so you can do the following:
set fold to (path to desktop)
tell application "Finder"
activate
make new folder at folder fold with properties {name:"My Amazing New
Folder"}
reveal result
end tell
In the above example, 'fold' is an alias because that's what's returned
by the 'path to' scripting addition. You can find other special folders
that 'path to' can work with by checking its definition in the Standard
Additions dictionary. As you become proficient in AppleScript, you may
find it easiest to deal with paths as strings or unicode text when
handling references to files. The first line above can be changed to
set fold to (path to desktop as string)
or
set fold to (path to desktop as unicode text) -- if you have a
sufficiently modern version of AS and Finder
in which case you store something which looks like this:
"Hard Drive:Users:formido:Desktop:"
to which you can append a name if you want to make a file
specification, or can convert to a Finder item or alias or file object,
or can parse for whatever other reason as the need arises.
Cheers,
Mike
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.