Re: Process nested folders
Re: Process nested folders
- Subject: Re: Process nested folders
- From: Nigel Garvey <email@hidden>
- Date: Tue, 5 Dec 2000 02:31:55 +0000
"Marc K. Myers" wrote on Mon, 04 Dec 2000 18:17:10 -0500:
>
Brad wrote:
>
> Date: Mon, 04 Dec 2000 10:59:07 -0800
>
> Subject: Process nested folders
>
> From: Brad <email@hidden>
>
> To: AppleScript list <email@hidden>
>
>
>
> Hello,
>
>
>
> I have a folder hierarchy for which I want to set window properties.
>
> Below is a script that works if I drag group of folders onto it.
>
> What I am looking for is to be able to drag the parent folder
>
> to the droplet and process all nested folders.
[snip]
>
This is the approach I would use:
>
>
on run
>
open ({choose folder})
>
end run
>
>
on open (itemList)
>
repeat with anItem in itemList
>
set theItem to the (contents of anItem) as text
>
if character -1 of theItem is ":" then
>
tell application "Finder"
>
set newList to items of alias theItem
>
end tell
>
open (newList)
>
procFldr(theItem)
>
end if
>
end repeat
>
end open
>
>
on procFldr(theFldr)
>
-- do something with the folder
>
end procFldr
It's very much faster to tell the Finder to fetch the folders of a
folder. That way you don't have to loop through every item to see what it
is. If you stick a beep in the procFldr() handler, you'll hear how much
faster it is.
on run
open ({choose folder})
end run
on open (itemList)
repeat with anItem in itemList
if folder of (info for anItem) then procFldr(anItem)
end repeat
end open
on procFldr(theFldr)
tell application "Finder"
repeat with anItem in (get every folder of theFldr)
my procFldr(anItem)
end repeat
end tell
beep -- do something with the folder
end procFldr
It would be faster still with 'get' omitted in procFldr(), but as Brad
wants to fool around with the folders themselves, its safer to
consolidate 'every folder' into an AppleScript list rather than leaving
it as a Finder reference. That way you'll know you're looping through the
subfolders in a fixed order.
NG