Avatar of mtthompsons
mtthompsons
 asked on

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

G:\Images

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

G:\Images

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

Thanks
VB Script

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
kulboy

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
        Next
    End if
End Sub

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

ASKER
Thanks

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

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)
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.