Solved

Vbscript Question : How can subfolders of a folder be listed ?

Posted on 2007-04-04
2
242 Views
Last Modified: 2012-05-05
please help
0
Comment
Question by:itbabe
[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
2 Comments
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 18849275

      Set objFolder = fs.GetFolder(sFolderName)
      Set objSubFolders = objFolder.SubFolders
      Set objFiles = objFolder.Files


      'count files
      iTotFiles=iTotFiles + objFiles.count
      'set to remove readonly
      Const READONLY = 1
      For Each xFile In objFiles
            xFile.Attributes = File.Attributes And Not READONLY
      Next

      For Each xFolder In objSubFolders
         xFolder.Attributes = xFolder.Attributes And Not READONLY
          ScanFolder (xFolder.Path)
      Next

      'count directories found
      itotdirs=itotdirs+1
      
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 18849283
sorry this should have
'====================
Sub ScanFolder(sFolderName)

      Dim objFolder, objSubFolders, objFiles
      Dim xFolder, xFile
      Dim ret

      On Error Resume Next

at the top....


You will note the function calls itself.....recursion.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.

726 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