Re: target of folder action
Re: target of folder action
- Subject: Re: target of folder action
- From: Kai <email@hidden>
- Date: Wed, 15 Jan 2003 23:16:03 +0000
on Tue, 14 Jan 2003 08:13:12 -0500, Gary Lists <email@hidden> wrote:
>
On or about 1/13/03 6:55 PM, Kai wrote:
>
>
>>>> If I write a script for a folder action part of which is to move files is
>
>>>> there a way I can tell the path to the folder the user has attached the
>
>>>> action to?
>
>>>>
>
>>>> Thanks
>
>>>>
>
>>>> Steve
>
>>
>
>> path to me
>
>
> That should return the path to the Folder Actions extension file.
>
Oops. Yes, that's the path to the actual script (at least it is for me.)
Something strange still seems to be happening here, Gary.
While that's the behaviour I'd expect from a script saved as an application,
my understanding is that 'path to me' in a Folder Action script should point
to the 'app' responsible for handling folder actions.
Depending on the System, that would normally be either the 'Folder Actions'
extension or 'System Events.app'.
>
> Try a folder action script along these lines instead:
>
>
>
> =====================================
>
>
>
> on opening folder this_folder
>
> display dialog (this_folder as string)
>
> end opening folder
>
>
>
> =====================================
>
>
>
> In this example, the variable 'this_folder' is the target (as an alias) of
>
> the folder action 'opening folder'.
>
>
>
Kai, with AS 1.8 this returns the path to the running script with the 'on'
>
folder action handler.
Again, I can't see how such behaviour could possibly be that effective for a
Folder Action.
For a Folder Action script to perform actions related to a selected folder,
the folder must surely be identified first. Without this ability, folder
actions would be limited to a somewhat general and indiscriminate set of
commands.
However, the Standard Additions dictionary confirms that Folder Actions do
indeed identify the target folder. For example:
-------------------------------------------------------------------
opening folder: Called after a folder has been opened into a window
opening folder alias -- the folder that was opened
-------------------------------------------------------------------
So a reference to the folder (as an alias) is assigned to a variable at the
beginning of Folder Action handlers ('on opening folder x', 'on closing
folder window for y', 'on moving folder window for z', etc.)...
By subsequently referring to the variable, the script can target the folder
specifically with certain commands - which is what my simple script example
did (OMM, at least).
I've now had similar Folder Action scripts tested independently on a couple
of different systems - to check what was returned by both 'path to me' and a
reference to the folder (represented below by the variable 'opened_folder').
In each case, a test folder (named 'Folder to open') was placed in the
documents folder.
The results confirm the above theory:
--------------------
OS 9.1 / AS 1.8.3
--------------------
path to me:
--> alias "Macintosh HD:System Folder:Extensions:Folder Actions"
opened_folder:
--> alias "Macintosh HD:Documents:Folder to open:"
--------------------
OS 10.2.3 / AS 1.9.1
--------------------
path to me:
--> alias "Macintosh HD:System:Library:CoreServices:System Events.app:"
opened_folder:
--> alias "Macintosh HD:Users:UserName:Documents:Folder to open:"
--------------------
If your configuration is returning the path to the running script (instead
of pointing to the relevant folder), I doubt that your Folder Actions are
working as they should. Are you using Folder Action scripts for anything
else - and how are they behaving?
--
Kai
_______________________________________________
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.