Vb script to create 1 folder with name "Posters" in all folders in specified path

mtthompsons used Ask the Experts™
Vb script to create 1 folder with name "Posters" in all folders in specified path

I need help with a script that can can check every folder in this path


Create 1 folder called "Posters" in every subdirectory available. I have


Within this i have 10 folders and within those 10 i have 1000+ in each

Need to create 1 folder each in all those 1000+ folders in each of those 10 folders

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("C:\Scripts"), 3

Sub ShowSubFolders(Folder, Depth)
    If Depth > 0 then
        For Each Subfolder in Folder.SubFolders
            Wscript.Echo Subfolder.Path
              ' do your folder creation stuff here...
            ShowSubFolders Subfolder, Depth -1
    End if
End Sub

you can set the folder depth in the parameter (here 3 for the example)



If i change to 3 just in the 3rd folder depth it will create a folder called "Posters"?

the script i gave you will do the itteration of the folders,  you will still need to create the folder itself.

look at where i say to do the folder creation magic

you could use something like this:

If Not FSO.FolderExists(newfolderpath) Then
Set newfolder = FSO.CreateFolder(newfolderpath)
IT / Software Engineering Consultant
Top Expert 2016
This should do what you describing, adding the new folder where needed.

strBaseDir = "g:\images"
strAddFolder = "Posters"

Set objFSO = CreateObject("Scripting.FileSystemObject")

objBaseDir = objFSO.GetFolder(strBaseDir)
For Each objSubFolderLevel1 in objBaseDir.SubFolders
   For Each objSubFolderLevel2 in objSubFolderLevel1.SubFolders
      strAddPath = objSubFolderLevel2 & "\" & strAddFolder
      If Not objFSO.FolderExists(strAddPath) Then objFSO.CreateFolder(strAddPath)

Open in new window


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial