Re: [Q] Get the folder the script is located in
Re: [Q] Get the folder the script is located in
- Subject: Re: [Q] Get the folder the script is located in
- From: "Gary (Lists)" <email@hidden>
- Date: Thu, 14 Sep 2006 11:33:39 -0400
"Eric Gorr" wrote:
> Michelle Steiner wrote:
>> On Sep 14, 2006, at 7:50 AM, Adam Bell wrote:
>>
>>>> I would like to be able to get the folder my applescript is located in.
>>>>
>>>> How can I do that?
>>>>
>>>> set myFolder to ( get folder ... )
>>>
>>> tell application "Finder" to set c to container of (path to me)
>>
>> That does not work for scripts that are run from Script Editor; it
>> returns the path to the script editor, and not to the script file.
>>
>> It does work if the script is saved as an application or if the script
>> is run from the script menu.
>
> Is there any more general way of doing it so this would work as well?
>
> I have been playing around with something like:
>
> set myFolder to (get folder of (info for me))
>
> but, this does not work.
'folder' (of) is a boolean property of the 'info for' result record,
indicating whether the passed item is or is not a folder. It has nothing to
do with the parent container or the path location.
>From the Standard Additions dictionary,
'Class file information : Reply record for the info for¹ command'
>> ...
>> folder boolean [r/o] -- Is the item a folder?
>> ...
You probably would benefit from a read-through of the dictionary for the
Standard Additions, to become more familiar with the 'info for' command and
with the result that command returns. It's very useful, just not in this
case. (And should prevent future frustration and lost time.)
--
Gary
_______________________________________________
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