• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: does anybody have a recursive directory subrountine???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
--------------------------------------------------


References: 
 >does anybody have a recursive directory subrountine??? (From: Andrew Simpson <email@hidden>)

  • Prev by Date: FW: [schemelist] OT: Disaster
  • Next by Date: Attachments to an existing message
  • Previous by thread: Re: does anybody have a recursive directory subrountine???
  • Next by thread: Re: does anybody have a recursive directory subrountine???
  • Index(es):
    • Date
    • Thread