Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

fso & subFolders question (loop through folder and subfolders to display files)

Posted on 2008-06-18
3
Medium Priority
?
1,182 Views
Last Modified: 2010-04-21
I am having a little trouble with the good ol fso fubfolder looping.  Here is what my folder structure looks like

Images
    accessories
           image 1
           image 2
    speakers
           image 1
           image 2
    car audio
           speakers
                   image 1
                   image 2
           head units
                   image 1
                   image 2

etc

I'm getting an error...

Microsoft VBScript runtime  error '800a01a8'
Object required: ''
/mc-high-res/Default.asp, line 37

What object am I goofing on?
Thanks
<%
dim fso,fileName,folderName,myMail,mailBody,subFolderName,imagesFolder,carSubFolder
set fso=Server.CreateObject("Scripting.FileSystemObject")
 
 
	'GRAB FOLDER
   imagesFolder = "E:\mcintosh-high-res-images\"
   carAudioFolder = imagesFolder & "CarAudio\"
 
    Set fso = CreateObject("Scripting.FileSystemObject") 
    Set allSubFolders = fso.GetFolder(imagesFolder) 	
	Set carSubFolders = fso.GetFolder(carAudioFolder)
	
	sub carAudiLoop
		for each subfolder in carSubFolders.subFolders
			carSubFolder = subfolder.Name
			Response.Write("<b>" & carSubFolder & "</b><ul>") 
			for each fileName in subfolder.files 
				response.write "<li>"& fileName.name & "</li>"
			next
			response.write "</ul>"
		next
	end sub
    
	
	
	
	for each subfolder in allSubFolders.subFolders 
	subFolderName = subfolder.Name
        Response.Write("<b>" & subfolderName & "</b><ul>") 
			
			if subFolderName = "CarAudio" then 			
				carAudiLoop
			end if
			
			for each fileName in subfolder.files 'LINE 37
				response.write "<li>"& fileName.name & "</li>"
			next
			response.write "</ul>"
    next 
    set fold = nothing 
    set fso = nothing 
 
%>

Open in new window

0
Comment
Question by:jweissdandm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Badotz earned 500 total points
ID: 21816328
Try this:
                        if subFolderName = "CarAudio" then                      
                                carAudiLoop
                        else
                        
                                for each fileName in subfolder.files 'LINE 37
                                        response.write "<li>"& fileName.name & "</li>"
                                next
                                response.write "</ul>"
                        end if

Open in new window

0
 
LVL 2

Author Closing Comment

by:jweissdandm
ID: 31656935
yup, that did it. Thanks
0
 
LVL 29

Expert Comment

by:Badotz
ID: 21816633
No worries - glad to help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question