Re: does anybody have a recursive directory subrountine???
Re: does anybody have a recursive directory subrountine???
- Subject: Re: does anybody have a recursive directory subrountine???
- From: Jim Schram <email@hidden>
- Date: Thu, 13 Sep 2001 12:41:30 -0700
At 12:53 PM +1200 2001/09/13, Andrew Simpson wrote:
>
I would like a subrountine that creates a list of all available files in all
>
avaialable folders no matter how deep they go into the hierachi from a
>
choosen disk or volume
>
>
anybody have any code, just lying around to do this???
Sure... here y'go.
Note that this version does not use recursion and therefore won't blow the stack even if the folder hierarchy is extremely deep... just give the applet more memory in the Get Info dialog if the total number of folders is extremely large. The script also does not rely on any OSAX or inconsistently implemented Finder commands. And is, of course, localization independent.
Have fun!
-- Jim
--------------------------------------------------
on open theItems
local theCurrentFolder
local theFolderList
local theFolderListIndex
tell application "Finder"
repeat with theItem in theItems
if file type of theItem is "fold" then
set theFolderList to {contents of theItem}
set theFolderListIndex to 1
repeat
if theFolderListIndex > length of theFolderList then exit repeat
set theCurrentFolder to item theFolderListIndex of theFolderList
set theFolderList to theFolderList & (every folder of theCurrentFolder)
set theFolderListIndex to theFolderListIndex + 1
end repeat
-- now do something with the list... like set each folder to view as list by kind
repeat with theCurrentFolder in theFolderList
open theCurrentFolder
set view of theCurrentFolder to 5
close theCurrentFolder
end repeat
end if
end repeat
end tell
end open
--------------------------------------------------