Re: Relative path
Re: Relative path
- Subject: Re: Relative path
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 01 Jul 2003 09:22:48 -0700
On 7/1/03 6:10 AM, "Justin" <email@hidden> wrote:
>
Hello. I have a newbie question. I have a series of AppleScripts that tell
>
an application to open several documents. Currently I have the absolute
>
path to these documents in the script (Macintosh HD:foldername:filename)
>
when I'd rather have a relative path so that this is more portable.
>
Relative to what? The running script? Is it being saved as a self-standing
script Application, or is it a compiled script running from a script menu?
This makes a hug difference. Are the documents going to be in the same
folder as the script (application) or somewhere else?
For example, if you could guarantee that the documents are going to be in
the same folder as a running script application, you would do:
set myPath to (path to me as string)
set oldTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set myFolderPath to (text items 1 thru -2 of myPath) as string & ":"
set AppleScript's text item delimiters to oldTids
set doc1 to alias (myFolderPath & "doc1Name")
Or you can find the container in the Finder but parsing the file path as
above works just as well, or better. It's best to put all this in a try
block in case the user has moved the docs. But by using the 'alias' format,
you can ensure that if this script is run once, the alias' can be saved as a
script property if desired - then the docs can be moved or renamed by the
user and will still be found in future as long as they still exist somewhere
on the computer. (Ask if you want to know more about this.)
--
Paul Berkowitz
_______________________________________________
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.