Krazymike is having a rough day.
strFolder = "C:\tempy\"
set objFSO = createobject("Scripting.FileSystemObject")
GetFolders strFolder
if not objFSO.FolderExists(strfolder & "\Edcom") then objFSO.CreateFolder
(strfolder & "\Edcom")
Sub getFolders(patH)
Dim f, fs
'msgbox path
Set fs = objFSO.GetFolder(patH)
For Each f In fs.subFolders
if f.name <> "Edcom" then
if not objFSO.FolderExists(f.path & "\Edcom") then
objFSO.CreateFolder (f.patH & "\Edcom")
Call getFolders(patH & f.Name & "\")
end if
Next
End Sub
"RemyMaza" <RemyMaza@xxxxxx> wrote in message
news:16e937fc-b94f-40ed-b37b-de46a679b195@xxxxxx
On Sep 11, 1:53 am, "Al Dunbar" <AlanD...@xxxxxx> wrote:
> "RemyMaza" <RemyM...@xxxxxx> wrote in message
>
> news:3492f357-6ec4-4a4f-ab55-afed1b71a3b3@xxxxxx
>
>
>
>
>
> > I'm having a bit of problems with this code and can't seem to get
> > passed it. >
> > '~~~~~~~~~~~~~~Code~~~~~~~~~~~~~~~ >>
> > strFolder = "C:\test\2008" >
> > set objFSO = createobject("Scripting.FileSystemObject") >>
> > sub GetFolders(byval strDirectory)
> > set objFolder = objFSO.GetFolder(strDirectory)
> > for each objFolder in objFolder.SubFolders
> > Set objFolder = objFSO.CreateFolder(strPath & "\" & "Edcom")
> > 'wscript.echo objFolder.Path
> > GetFolders objFolder.Path
> > next
> > end sub >
> > '~~~~~~~~~~~~~~End~~~~~~~~~~~~~~ >
> > What happens when I uncomment the wscript echo, I get a nice prompt
> > with the correct path of ALL of the sub folders as expected. However,
> > when I run it trying to create folders using the same logic, I only
> > create one folder within the 2008 folder. What am I doing wrong? >
> Your code does not define the variable called strPath.
>
> /Al- Hide quoted text -
>
> - Show quoted text - I see the mistake and have made the change but I'm still not getting
the expected results. When I uncomment the wscript.echo, I see all of
the folders and subfolders and subfolders of the subfolders. When I
activate the folder create code, I get folders in only the first
subfolders. I have these folders within the 2008 directory:
1. New Folder
2. New Folder(2)
3. New Folder(3)
These all get the new folder "Edcom" but their subdirectories do not
even though they are echo'd to me.
'~~~~~~~~~~~~~~Code~~~~~~~~~~~~~~~
Dim strFolder
strFolder = "C:\test\2008"
set objFSO = createobject("Scripting.FileSystemObject")
GetFolders strFolder
sub GetFolders(byval strDirectory)
set objFolder = objFSO.GetFolder(strDirectory)
for each objFolder in objFolder.SubFolders
Set objFolder = objFSO.CreateFolder(objFolder.Path &
"\" & "Edcom")
'wscript.echo objFolder.Path
GetFolders objFolder.Path
next
end sub
'~~~~~~~~~~~~~~End~~~~~~~~~~~~~~
Thanks,
Matt