Recursive Directory Walker for really huge numbers of files

Sivakatirswami katir at hindu.org
Thu May 9 16:58:01 EDT 2002


Geoff wrote:

> This processes 10,000 files at about 400 files per second on my G3 400's boot
> drive:
 Excellent, thanks, Geoff, that confirmed that it works, which was
important... but in addition to the problematic line that called for the
line count of the global, over and over again.... woe betides the sysadmin
where the staff has used slashes in their folder or file names (smile) at
which point the script goes into infinite recursion: I uncommented your "put
whatFolder" and had fun watching this string being built continously until I
hit cmd-.

A few manual fixes on folder and file names and the script ran fine.

/Sivakatirswami/Desktop Folder/Revolution 1.1.1 Classic/ ktsRevData/
StudyHall/MysticMouse/Images-parts and
Pieces/../../../../../../../../../../../../../../../../../../../../../../../
../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../../../../../../../../../../../..
/ etc.


global gHierList,gMainFolder,gBaseLevels
local tCount

on mouseUp
  put the ticks into tStart
  put "" into gHierList
  answer folder "Pick a folder you want to walk:"
  put it into gMainFolder
  if gMainFolder = "" then exit mouseUp
  set the itemDel to "/"
  put 0 into tCount
  put the number of items of gMainFolder into gBaseLevels
  directoryWalk gMainFolder
  put gHierList into field "result"
  put tCount && (tCount*60/(ticks()-tStart))
end mouseUp

on directoryWalk whatFolder
put whatFolder
  --exit to top
  set the itemDel to "/"
  set the directory to whatFolder
  put the files into temp
  add the number of lines of temp to tCount
  filter temp with "*.html"
  sort temp
  repeat for each line x in temp
    put whatFolder & "/" & x & cr after gHierList
  end repeat
  put the folders into tDirList
  sort tDirList
  delete line 1 of tDirList
  repeat for each line x in tDirList
    directoryWalk (whatFolder & "/" & x)
  end repeat
end directoryWalk

Om shanti,
Hinduism Today

Sivakatirswami
Editor's Assistant/Production Manager
katir at hindu.org 
www.HinduismToday.com, www.HimalayanAcademy.com,
www.Gurudeva.org, www.hindu.org

Read The Master Course Lesson of the Day at
http://www.gurudeva.org/lesson.shtml




More information about the metacard mailing list