Making folders....

  • Thread starter Thread starter Zadig Galbaras
  • Start date Start date
Z

Zadig Galbaras

Is there a software designed to make a set of subfolders in a tree of
folder?

I mean, I have f eks ten folders named 1 through 10.
Under each there is many subfolders named A through Z

Is there a snappy way to make a set of subfolders to each of these 260
folders?

--

regards
Zadig Galbaras
A Perturbed Norwegian Agnostic
-
 
Zadig said:
Is there a software designed to make a set of subfolders
in a tree of folder?

I mean, I have f eks ten folders named 1 through 10.
Under each there is many subfolders named A through Z

Is there a snappy way to make a set of subfolders to each
of these 260 folders?

Hei Zadig (ikke akkurat et standard norsk navn må jeg si :-)

You can use a VBScript for this. Put the script below in a file with
a .vbs extension, and run it by double clicking on it.

You need to adjust the data in the two variables sBaseFolder and
aNewFolders .


'--------------------8<----------------------
' Script that will populate a folder structure with a set
' of new folders
'


' Define the base folder path
' (the one containing the folders named 1 through 10)
sBaseFolder = "C:\some1\some2"

' list all new folders to be created here
aNewFolders = Array("new1", "new2", "new3")

Set oFSO = CreateObject("Scripting.FileSystemObject")

On Error Resume Next
For i = 1 To 10
For n = Asc("A") To Asc("Z")
sFolder = sBaseFolder & "\" & i & "\" & Chr(n)
If oFSO.FolderExists(sFolder) Then
For Each sNewFolder In aNewFolders
oFSO.CreateFolder sFolder & "\" & sNewFolder
Next
End If
Next
Next

MsgBox "Finished!", vbInformation + vbSystemModal, "Populate folders"

'--------------------8<----------------------



WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 
Hi Torgeir!
(Zadig er et nick da vettu. Har "ø" i navnet mitt, og brukt dette nicket
siden rundt den tiden første romferga ekploderte)

Thanks Torgeir, this was exactly what I was asking for, but not what I
needed :-)
My mistake...

I have this folder structure where the folders are named after every country
on the planet.
I want to create subfolders into these, i.e. into all subfolders under a
certain folder.
I want to create maybe as many as five or more subfolders in every
subfolders in the folder tree.

So a software which looks for subfolders of any name, and then, if any found
create subfolders in it according to a list would do the trick.
And of course if the named subfolder exist, continue without creating a new
one.
If you catch my drift....

Anyone know about a program which can do this job without me having to
retype close to two hundred folders with maybe as many as ten subfolders?

--

regards
Zadig Galbaras
A Perturbed Norwegian Agnostic
-
 
Zadig said:
Hi Torgeir!
(Zadig er et nick da vettu. Har "ø" i navnet mitt, og brukt dette
nicket siden rundt den tiden første romferga ekploderte)

Thanks Torgeir, this was exactly what I was asking for, but not
what I needed :-)
My mistake...

I have this folder structure where the folders are named after
every country on the planet.
I want to create subfolders into these, i.e. into all subfolders
under a certain folder.
I want to create maybe as many as five or more subfolders in every
subfolders in the folder tree.
Hei Øyvind :-)

Ok, here is another script that should do the job the way you really
meant it:

'--------------------8<----------------------
' Script that will populate subfolders with a set of new folders
'

' Define the base folder path
' (the one containing the subfolders named after countries)
sBaseFolder = "C:\some1\some2"

' list all new folders to be created here,
' new1/new2/new3 is just example names you need to change
aNewFolders = Array("new1", "new2", "new3")


Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oFolder = oFSO.GetFolder(sBaseFolder)

' enumerate all the subfolders
For Each oSubFolder In oFolder.SubFolders
sSubFolder = oSubFolder.Path
For Each sNewFolder In aNewFolders
If Not oFSO.FolderExists(sSubFolder & "\" & sNewFolder) Then
oFSO.CreateFolder sSubFolder & "\" & sNewFolder
End If
Next
Next

MsgBox "Finished!", vbInformation + vbSystemModal, "Populate folders"

'--------------------8<----------------------
 
Hi Torgeir....(Porsgrunn er sikkert en fin by)

This did the trick, except it didn't do the trick in ALL the subfolders.
Just the subfolders on the root level.
But this is what I've been looking for.

You see the folders for each country are located as a subfolder to each
parts of the world like this

The news in Buskerud would be found in C:\The World\Europe\Norway\Buskerud\
And under these folders i.e. C:\The World\ and C.\The World\Europe\ and
C:\The World\Europe\ and C:\The World\Europe\Norway\ and C:\The
World\Europe\Norway\Buskerud\ I want to add the subfolders of my choice.

This is just a start page idea I will make available free to anyone on my
website if I get it right :-)

--

regards
Zadig Galbaras
A Perturbed Norwegian Agnostic
-
 
Zadig said:
Hi Torgeir....(Porsgrunn er sikkert en fin by)

This did the trick, except it didn't do the trick in ALL the
subfolders. Just the subfolders on the root level.
But this is what I've been looking for.

You see the folders for each country are located as a subfolder
to each parts of the world like this

The news in Buskerud would be found in C:\The World\Europe\
Norway\Buskerud\ And under these folders i.e. C:\The World\ and
C.\The World\Europe\ and C:\The World\Europe\ and C:\The World\
Europe\Norway\ and C:\The World\Europe\Norway\Buskerud\ I want
to add the subfolders of my choice.

This is just a start page idea I will make available free to
anyone on my website if I get it right :-)
Hi,

Ok, maybe I will succeed on my third try :-)

Below are two different scripts.

The first one will create the folders defined in the aNewFolders array
variable in *all* existing folders starting with the folder defined in
the sBaseFolder variable and all it's subfolders.

The second script is a version that will create new folders only at
the subfolder level count specified in the iSubfolderLevel variable.


First script:

'--------------------8<----------------------

' Script that will populate new folders in all existing folders
' starting with the folder defined in the sBaseFolder variable
' and all it's subfolders.

' Define the base folder path
sBaseFolder = "C:\The World"

' list all new folders to be created here,
' new1/new2/new3 is just example names you need to change
aNewFolders = Array("new1", "new2", "new3")

Set oFSO = CreateObject("Scripting.FileSystemObject")

Call CreateFolders(sBaseFolder)

MsgBox "Finished!", vbInformation + vbSystemModal, "Populate folders"


Sub CreateFolders(sFolder)

Set oFolder = oFSO.GetFolder(sFolder)

' enumerate all the subfolders
For Each sFldr In oFolder.SubFolders
CreateFolders sFldr
Next

For Each sNewFolder In aNewFolders
If Not oFSO.FolderExists(sFolder & "\" & sNewFolder) Then
oFSO.CreateFolder sFolder & "\" & sNewFolder
End If
Next

End Sub

'--------------------8<----------------------





Second script:

'--------------------8<----------------------

' Script that will create new folders only at the subfolder level
' count specified in the iSubfolderLevel variable.


' Define the base folder path
sBaseFolder = "C:\The World"

' Defining at what subfolder level the new folders are to be created
' If you set it to 0, the folders will be created in the base folder
iSubfolderLevel = 3

' list all new folders to be created here,
' new1/new2/new3 is just example names you need to change
aNewFolders = Array("new1", "new2", "new3")

Set oFSO = CreateObject("Scripting.FileSystemObject")

Call CreateFolders(sBaseFolder)

MsgBox "Finished!", vbInformation + vbSystemModal, "Populate folders"


Sub CreateFolders(sFolder)

sRelativePath = Mid(sFolder, Len(sBaseFolder)+1)

If CharCount(sRelativePath, "\") = iSubfolderLevel Then

For Each sNewFolder In aNewFolders
If Not oFSO.FolderExists(sFolder & "\" & sNewFolder) Then
oFSO.CreateFolder sFolder & "\" & sNewFolder
End If
Next

Else
Set oFolder = oFSO.GetFolder(sFolder)

' enumerate all the subfolders
For Each sFldr In oFolder.SubFolders
CreateFolders sFldr
Next
End If

End Sub


Function CharCount(sString, sChar)

If Len(sChar) <> 1 Or sString = "" Then
CharCount = 0 : Exit Function
End If

Select Case sChar
Case "\", "$", "*", "+", "?", ".", "(", ")", "|"
sChar = "\" & sChar
End Select

With New RegExp
.Pattern = sChar
.IgnoreCase = True
.Global = True
CharCount = .Execute(sString).Count
End With

End Function

'--------------------8<----------------------
 
WOW, togir is not spamming but answering questions. WOW!!
Zadig you are so lucky he is not spamming you as he does most people.
 
David said:
WOW, togir is not spamming but answering questions. WOW!!
Zadig you are so lucky he is not spamming you as he does most
people.

<LOL> Yes, he must have been born under a lucky star or something :-)
 
Hi David...
This is my first encounter with Torgeir, and he's been treating me nice,
very nice indeed.
Why should I think different of him?

I like to make up my own opinion about others in disregard of origin.
Even people around me whom I consider scumbags have friends.
They, of some reason unknown to me, treat me different than those they make
friends with.
Life is good!

I'll get back to you Torgeir after my test of your latest script.


--

regards
Zadig Galbaras
A Perturbed Norwegian Agnostic
-


"David Candy" <.> skrev i melding
WOW, togir is not spamming but answering questions. WOW!!
Zadig you are so lucky he is not spamming you as he does most people.
--
 
Hi Torgeir

The last script did the trick, but.....(don't laugh!)

After clicking on the vbs file a few times not realizing it was actually
working, my test area had 87 379 - nearly ninety thousand folders...!!!
(hehehehe!!!)

This is excatly what I was looking for....

Now I must find out why my computer reboots every now and then...
Very irritating..

See you all in another thread...


--

regards
Zadig Galbaras
A Perturbed Norwegian Agnostic
-
 
David,

I have never seen Torgeir spam and look forward to each of his posts here as
well as yours for valid information.

--

All the Best,
Kelly (MS-MVP)

Troubleshooting Windows XP
http://www.kellys-korner-xp.com



"David Candy" <.> wrote in message
WOW, togir is not spamming but answering questions. WOW!!
Zadig you are so lucky he is not spamming you as he does most people.
 
Zadig said:
Hi Torgeir

The last script did the trick, but.....(don't laugh!)

After clicking on the vbs file a few times not realizing it was
working, my test area had 87 379 - nearly ninety thousand
folders...!!! (hehehehe!!!)

This is excatly what I was looking for....


Great! A good thing you played around on a test area first :-)

Now I must find out why my computer reboots every now and then...
Very irritating..

See you all in another thread...

Good luck with your reboot problem, those are pretty irritating,
that is for sure...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top