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

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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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)
mtthompsonsAuthor Commented:

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)
Bill PrewIT / Software Engineering ConsultantCommented:
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.