Re: Need to search a folder and sub folders for files
Re: Need to search a folder and sub folders for files
- Subject: Re: Need to search a folder and sub folders for files
- From: Jolly Roger <email@hidden>
- Date: Tue, 13 Feb 2001 16:41:19 -0600
- Replyto: email@hidden
on 2/13/2001 2:50 PM, Bob Bader (email@hidden) wrote:
>
Howdy list,
>
>
>
I am looking for a script that will search through a folder (and infinite
>
levels of sub folders) looking at all the files.
You either need to use a scripting addition, or a recursive handler.
If you want to use a scripting addition, I recommend FindFile
(
http://MicrocosmSoftware.com/findfileosax.html).
If you want to use a recursive handler, then the following script may be
helpful to you:
-- begin script
set folderPath to (choose folder with prompt "Choose a folder to list:") as
text
tell FolderLister to Listfolder(folderPath)
script FolderLister
global fileList
on GetFileList(pathToFolder)
set theListRef to a reference to list folder pathToFolder without
invisibles
repeat with nextItem in theListRef
set itemPath to pathToFolder & nextItem
if folder of (info for alias itemPath) then
GetFileList(itemPath & ":")
else
set the fileList to fileList & itemPath
end if
end repeat
end GetFileList
on Listfolder(pathToFolder)
set fileList to {}
GetFileList(pathToFolder)
return fileList
end Listfolder
end script
-- end script
(Watch for line breaks and character conversions performed by the list
server.)
HTH
JR