Windows Vista Forums

Enumerating Folders
  1. #1


    RemyMaza Guest

    Enumerating Folders

    I'm having a bit of problems with this code and can't seem to get
    passed it.





    '~~~~~~~~~~~~~~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(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?

    Thanks,
    Matt

      My System SpecsSystem Spec

  2. #2


    Al Dunbar Guest

    Re: Enumerating Folders


    "RemyMaza" <RemyMaza@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~~~~~~~~~~~~~~~
    >
    >
    > 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(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



      My System SpecsSystem Spec

  3. #3


    RemyMaza Guest

    Re: Enumerating Folders

    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~~~~~~~~~~~~~~~
    >

    > > 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(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

      My System SpecsSystem Spec

  4. #4


    krazymike Guest

    Re: Enumerating Folders

    Dim strFolder

    strFolder = "C:\test\2008\"

    set objFSO = createobject("Scripting.FileSystemObject")

    GetFolders strFolder
    Sub getFolders(patH)
    Dim f, fs
    Set fs = objFSO.GetFolder(patH)
    For Each f In fs.Folders
    objFSO.CreateFolder (patH & f.Name & "\")
    Call getFolders(patH & f.Name & "\")
    Next f
    End Sub

      My System SpecsSystem Spec

  5. #5


    krazymike Guest

    Re: Enumerating Folders

    Sorry, I didn't finish customizing my code. It's from a different
    script.

    strFolder = "C:\tempy\"
    set objFSO = createobject("Scripting.FileSystemObject")
    GetFolders strFolder

    Sub getFolders(patH)
    Dim f, fs
    'msgbox path
    Set fs = objFSO.GetFolder(patH)
    For Each f In fs.subFolders
    if not objFSO.FolderExists(path & "\Edcom") then
    objFSO.CreateFolder (patH & "\Edcom")
    Call getFolders(patH & f.Name & "\")
    Next
    End Sub

      My System SpecsSystem Spec

  6. #6


    Mike Guest

    Re: Enumerating Folders

    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~~~~~~~~~~~~~~~
    >

    > > 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(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



      My System SpecsSystem Spec

  7. #7


    krazymike Guest

    Re: Enumerating Folders

    Thank you!! I am.

      My System SpecsSystem Spec

  8. #8


    RemyMaza Guest

    Re: Enumerating Folders

    On Sep 11, 2:05*pm, "Mike" <nos...@xxxxxx> wrote:

    > 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" <RemyM...@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~~~~~~~~~~~~~~~
    >

    > > > 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(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- Hide quoted text -
    >
    > - Show quoted text -
    That looks like hotness. I'll try it tonight. THANKS to all!

    Cheers,
    Matt

      My System SpecsSystem Spec

  9. #9


    RemyMaza Guest

    Re: Enumerating Folders

    On Sep 11, 2:05*pm, "Mike" <nos...@xxxxxx> wrote:

    > 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" <RemyM...@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~~~~~~~~~~~~~~~
    >

    > > > 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(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- Hide quoted text -
    >
    > - Show quoted text -
    Works like a charm... Thank you very much.

    Matt

      My System SpecsSystem Spec

Enumerating Folders problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
enumerating empty groups Salty PowerShell 6 24 Feb 2010
Enumerating IIS 6 App Pools xWakawaka PowerShell 4 14 Jan 2008
Enumerating Uninstall Key from Registry greatbarrier86 PowerShell 4 24 Aug 2007
Enumerating the Registry... ross m. greenberg Vista General 2 19 Aug 2007
Enumerating printers in WPF google@alphazeta.net Avalon 0 17 May 2007