Link to home
Create AccountLog in
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
Avatar of kulboy
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)
Avatar of mtthompsons

ASKER

Thanks

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)
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account