Re: Jons Commands "Walk Folders"
Re: Jons Commands "Walk Folders"
- Subject: Re: Jons Commands "Walk Folders"
- From: Jon Pugh <email@hidden>
- Date: Mon, 2 Jun 2003 21:21:20 -0700
At 5:17 PM -0500 6/2/03, email@hidden wrote:
>
I am looking to use the esteemed Jons Commands, using "walk folders" to perform recursive actions based upon file type nested in a directory. However, I must confess that I do not understand how exactly to implement the walk folders.
>
>
It uses a script object that is just not a way I'm used to writing scripts. The rest looks straight forward enough, can someone provide an example mainly telling me about how this script object part is used? TIA
The trick with "walk folders" is that your script object's open handler is called once with each file.
So:
script foo
property fileList : {}
on open (theFile)
copy theFile as string to end of fileList
--display dialog theFile as string
return fileList
end open
end script
This is a script object with a property and an open handler. The open handler adds the theFile alias (just for you, John) to the end of the fileList list and then returns the list just in case it is the last call.
The "walk folders" command returns whatever the last open handler returned.
Here's an easy way to call it, by saving this (and the script above) as an application (i.e. droplet) and dropping some files and/or folders on it:
on open (theFiles)
set fl to walk folders theFiles with script foo
display dialog (number of items of fl) as string
end open
(Personally, I just put this script in a Script Debugger window and drag files and/or folders to the window, where Script Debugger offers to pass them to the script's open handler. Can Smile do that, Emmanuel?)
So, before you call "walk folders" you can prepare your script object once, but each time the open handler has to act like this is the last time it will be called and return something, if you want anything returned, as opposed to written to a file or whatever.
Any questions?
Jon
_______________________________________________
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.