Re: Accessing the Desktop & directory path specifications
Re: Accessing the Desktop & directory path specifications
- Subject: Re: Accessing the Desktop & directory path specifications
- From: kai <email@hidden>
- Date: Wed, 1 Dec 2004 00:02:00 +0000
On Tue, 30 Nov 2004 10:07:45 -0700, Ken G. Brown wrote:
I'm needing to script access to the same file on the Desktop of several
different computers and signons. I could store the script in a folder
in the
Documents folder then within the script refer relatively up two levels
and
then down one onto the Desktop but I am unsure of how to do this
specification in the open.
Is there a nifty standardized way to access the local Desktop or to
otherwise accomplish this type of thing?
As already mentioned, Ken, you could use the 'path to' command from
Standard Additions. In the case of the desktop, any of the following
'path to' variations should work:
path to "desk"
path to desktop
path to desktop folder
Obviously a little more work is required to identify a particular file.
For example, to get a file path or alias, we could (assuming the name
of the required file is "filename") use something like:
------------
set filePath to (path to desktop as Unicode text) & "filename"
--> "Macintosh HD:Users:Username:Desktop:filename"
set fileAlias to filePath as alias
--> alias "Macintosh HD:Users:Username:Desktop:filename"
set fileSpec to filePath as file specification
--> file "Macintosh HD:Users:Username:Desktop:filename"
[etc...]
------------
The Standard Additions dictionary shows a few possible parameters for
the 'path to' command, some of which are available only on Mac OS 9 and
others only on Mac OS X.
In addition, the command works on many other values (four-character
codes) that do not have terms defined for them. While the following
characters may not all display correctly on-list, you might like to
play with a few of the codes - only some of which will work on a given
Mac OS version. (Be aware though that, where certain items do not
exist, they may be automatically created by the 'path to' command.)
------------
"acmp", "adio", "aexƒ", "åexƒ", "alrt", "amnu", "aplg", "appr", "apps",
"åpps", "asnd", "astƒ", "åstƒ", "asup", "auth", "bank", "boot", "cach",
"carb", "ccmm", "cmnu", "cmpd", "cscr", "csrv", "ctrD", "ctrl", "cusr",
"ddoc", "desk", "devf", "devh", "dlib", "docs", "dplg", "dspl", "dsrv",
"dtop", "dtpƒ", "egfp", "empt", "extD", "extn", "fall", "fasf", "favs",
"fbcf", "fbcp", "flnt", "fnds", "font", "fram", "fsys", "fvoc", "ilgf",
"îlgf", "impr", "info", "intƒ", "întƒ", "issd", "issf", "kchn", "kext",
"laun", "macD", "macs", "mdoc", "midi", "morƒ", "mpxf", "oded", "odlb",
"odod", "odsp", "odst", "ødst", "pdoc", "pfrm", "ppdf", "pplg", "pref",
"prnt", "prof", "pubb", "qtex", "rapp", "rcpt", "rdoc", "root", "rsvr",
"rusf", "rusr", "scrƒ", "sctl", "sdat", "sdev", "sdsk", "shar", "shdD",
"shdf", "site", "snds", "spch", "spki", "sprf", "srvƒ", "ssnd", "ßrvƒ",
"strD", "strs", "strt", "sync", "temp", "thme", "trip", "trsh", "usrs",
"utiƒ", "ütiƒ", "utmp", "vsfd", "walk", "wcmp", "µdoc", "µorƒ", "ƒedi",
"ƒhlp", "ƒlib", "ƒloc", "ƒmod", "ƒnet", "ƒodf", "ƒprd", "ƒscr", "ƒtex"
------------
Usually, a particular domain can also be specified. For instance:
------------
path to "dlib"
--> alias "Macintosh HD:System:Library:"
path to "dlib" from System domain
--> alias "Macintosh HD:System:Library:" (in this case, same as default
above)
path to "dlib" from local domain
--> alias "Macintosh HD:Library:"
path to "dlib" from network domain
--> alias "Macintosh HD:Network:Library:"
path to "dlib" from user domain
--> alias "Macintosh HD:Users:Username:Library:"
------------
However, having said all that, there's a very useful alternative (and
often overlooked) method of accessing desktop items - using just the
Finder. Any "loose" items on the desktop can be considered elements of
either the desktop or of the Finder. So if a file's path is omitted,
the Finder will look for it on the desktop. This can greatly simplify
matters if, for example, we wish to open a desktop item:
------------
tell application "Finder" to open file "filename"
------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden