Re: Getting the current directory
Re: Getting the current directory
- Subject: Re: Getting the current directory
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 16 Nov 2004 13:06:09 -0800
On 11/16/04 12:43 PM, "Ken Brooks" <email@hidden> wrote:
> I would like to get a file reference (or alias) to the directory containing
> the script that is running. Is there a way to do this?
>
> Documentation seems to say that unqualified filenames will be interpreted
> relative to this directory, but I'm not seeing that. Can someone tell me what
> directory is actually used?
If you're referring to self-standing script applications (applets) or to
script documents running from the system's Script menu _in Panther only_
then, yes, this can be done:
tell application "Finder" to set myDirectory to container of (path to
me) as alias
Use 'as Unicode text' instead of ' as alias' to get just the path.
It's a little more contorted (but perhaps more reliable for the future?) in
System Events:
tell application "System Events" to set myDirectory to (path of
container of (path to me)) as alias
Omit the 'as alias' to get just the path (as Unicode text).
In the case of script documents run from other script menus or a script
editor, 'path to me' returns the application running the script (Script
Debugger has a preference to return the path to a saved script).
--
Paul Berkowitz
_______________________________________________
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