![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | Re: Enumerating Folders "RemyMaza" <RemyMaza@xxxxxx> wrote in message news:3492f357-6ec4-4a4f-ab55-afed1b71a3b3@xxxxxx Quote: > 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? /Al |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Enumerating Folders On Sep 11, 1:53*am, "Al Dunbar" <AlanD...@xxxxxx> wrote: Quote: > "RemyMaza" <RemyM...@xxxxxx> wrote in message > > news:3492f357-6ec4-4a4f-ab55-afed1b71a3b3@xxxxxx > > > > > Quote: > > I'm having a bit of problems with this code and can't seem to get > > passed it. Quote: > > '~~~~~~~~~~~~~~Code~~~~~~~~~~~~~~~ Quote: > > Dim strFolder Quote: > > strFolder = "C:\test\2008" Quote: > > set objFSO = createobject("Scripting.FileSystemObject") Quote: > > GetFolders strFolder Quote: > > 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 Quote: > > '~~~~~~~~~~~~~~End~~~~~~~~~~~~~~ Quote: > > 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 - 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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: Quote: > "RemyMaza" <RemyM...@xxxxxx> wrote in message > > news:3492f357-6ec4-4a4f-ab55-afed1b71a3b3@xxxxxx > > > > > Quote: > > I'm having a bit of problems with this code and can't seem to get > > passed it. Quote: > > '~~~~~~~~~~~~~~Code~~~~~~~~~~~~~~~ Quote: > > Dim strFolder Quote: > > strFolder = "C:\test\2008" Quote: > > set objFSO = createobject("Scripting.FileSystemObject") Quote: > > GetFolders strFolder Quote: > > 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 Quote: > > '~~~~~~~~~~~~~~End~~~~~~~~~~~~~~ Quote: > > 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 - 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 Specs![]() |
| | #7 (permalink) |
| | Re: Enumerating Folders Thank you!! I am. |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Enumerating Folders On Sep 11, 2:05*pm, "Mike" <nos...@xxxxxx> wrote: Quote: > 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: > > > > > Quote: > > "RemyMaza" <RemyM...@xxxxxx> wrote in message Quote: > >news:3492f357-6ec4-4a4f-ab55-afed1b71a3b3@xxxxxx Quote: Quote: > > > I'm having a bit of problems with this code and can't seem to get > > > passed it. Quote: Quote: > > > '~~~~~~~~~~~~~~Code~~~~~~~~~~~~~~~ Quote: Quote: > > > Dim strFolder Quote: Quote: > > > strFolder = "C:\test\2008" Quote: Quote: > > > set objFSO = createobject("Scripting.FileSystemObject") Quote: Quote: > > > GetFolders strFolder Quote: Quote: > > > 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 Quote: Quote: > > > '~~~~~~~~~~~~~~End~~~~~~~~~~~~~~ Quote: Quote: > > > 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? Quote: > > Your code does not define the variable called strPath. Quote: > > /Al- Hide quoted text - Quote: > > - 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 - Cheers, Matt |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Enumerating Folders On Sep 11, 2:05*pm, "Mike" <nos...@xxxxxx> wrote: Quote: > 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: > > > > > Quote: > > "RemyMaza" <RemyM...@xxxxxx> wrote in message Quote: > >news:3492f357-6ec4-4a4f-ab55-afed1b71a3b3@xxxxxx Quote: Quote: > > > I'm having a bit of problems with this code and can't seem to get > > > passed it. Quote: Quote: > > > '~~~~~~~~~~~~~~Code~~~~~~~~~~~~~~~ Quote: Quote: > > > Dim strFolder Quote: Quote: > > > strFolder = "C:\test\2008" Quote: Quote: > > > set objFSO = createobject("Scripting.FileSystemObject") Quote: Quote: > > > GetFolders strFolder Quote: Quote: > > > 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 Quote: Quote: > > > '~~~~~~~~~~~~~~End~~~~~~~~~~~~~~ Quote: Quote: > > > 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? Quote: > > Your code does not define the variable called strPath. Quote: > > /Al- Hide quoted text - Quote: > > - 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 - Matt |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Enumerating IIS 6 App Pools | PowerShell | |||
| Enumerating Uninstall Key from Registry | PowerShell | |||
| Enumerating the Registry... | Vista General | |||
| Enumerating group membership & ADSI | PowerShell | |||