I used the following code to search through my “galleries” folder and search for images through every folder inside galleries sub-folders.

Huh?

I used each folder inside of galleries as the “category” for each set of images. What it ended up doing was this. Each time I wanted to create a new category I would just make a new folder inside of “galleries”, each time I wanted a new album I’d put another folder inside each category folder. For example I could have a folder structure as follows:
/galleries
—/wedding
——-/getting_ready
——-/court_house
——-/reception
—/first_home
——-/before
——-/after

As you can see my categories are under galleries and they are called “wedding” and “first_home”. My galleries are called “getting_ready”, “court_house”, “reception”, “before” and “after”.

Oh I see!

I’m not going to be releasing the code to the entire program because an ex co-worker of mine and I plan on selling a gallery solution based on this, but here is the code for the folder searching! It is possible to modify this to do a full recursive search, I’ve done it before. Try creating another folder search function, while building the folder path you are passing into the functions as you go. It’s possible to build a recursive output that will show every file in an entire site directory, if you set root_folder = “/”

The Code

root_folder = “/galleries/”
SearchFolders root_folder

Sub SearchFolders(root_folder)
set FileSysObj=CreateObject(“Scripting.FileSystemObject”)
strFullPath = server.mappath(root_folder)
set fldr=FileSysObj.GetFolder(strFullPath)
set FolderList = fldr.SubFolders
For Each FolderIndex in FolderList
Response.Write(FolderIndex.name & ”
“)
Next
set FileList = fldr.Files
For Each FileIndex in FileList
Response.Write(FileIndex.name & ”
“)
Next
End Sub

Sub DisplaySubFolders(root_folder, parent_folder)
set FileSysObj=CreateObject(“Scripting.FileSystemObject”)
strFullPath = server.mappath(root_folder)
set fldr=FileSysObj.GetFolder(strFullPath)
set FolderList = fldr.SubFolders
For Each FolderIndex in FolderList
Response.Write(FolderIndex.name & ”
“)
Next
set FileList = fldr.Files
For Each FileIndex in FileList
Response.Write(FileIndex.name & ”
“)
Next
End Sub

Enjoy,
JJ