![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Get Folder Names I want to loop through all of the sub folders in c:\documents and settings\ and get their names. Can this be done with fso.GetFolder? If so, does anyone have a good link or some sample code I could take a look at? James |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Get Folder Names James wrote: Quote: > I want to loop through all of the sub folders in c:\documents and settings\ > and get their names. Can this be done with fso.GetFolder? If so, does > anyone have a good link or some sample code I could take a look at? > > James > There are several examples to be found in the fso section of the scripting documentation. And probably more examples on the ms "Scripting Guys and Girls" website. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Get Folder Names I am trying to delete all of the cookies files in everyone's user profile. Here is what I found but I am getting an error that the path cannot be found when the code tries to delete the files in the cookies folder. The echo part works fine. See any problems? Set objFSO = CreateObject("Scripting.FileSystemObject") strFolder = "c:\documents and settings\" Set objFolder = objFSO.GetFolder(strFolder) Set colFolders = objFolder.SubFolders For Each objSubFolder In colFolders If objSubFolder.Path <> "C:\Documents and Settings\Default User" Or objSubFolder.Path <> "C:\Documents and Settings\All Users" Or objSubFolder.Path <> "C:\Documents and Settings\LocalService" Or objSubFolder.Path <> "C:\Documents and Settings\NetworkService" Then objFSO.DeleteFile(objSubFolder.Path & "\Cookies\*.*") End If WScript.Echo objSubFolder.Path Next James "mr_unreliable" <kindlyReplyToNewsgroup@xxxxxx> wrote in message news:eDCjU%23mJKHA.5956@xxxxxx Quote: > > > James wrote: Quote: >> I want to loop through all of the sub folders in c:\documents and >> settings\ and get their names. Can this be done with fso.GetFolder? If >> so, does anyone have a good link or some sample code I could take a look >> at? >> >> James > hi James, > > There are several examples to be found in the fso section of the scripting > documentation. > > And probably more examples on the ms "Scripting Guys and Girls" > website. > > cheers, jw > ____________________________________________________________ > > You got questions? WE GOT ANSWERS!!! ..(but, no guarantee > the answers will be applicable to the questions) |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Get Folder Names On Aug 26, 4:44*pm, "James" <donotemai...@xxxxxx> wrote: Quote: > I am trying to delete all of the cookies files in everyone's user profile.. > Here is what I found but I am getting an error that the path cannot be found > when the code tries to delete the files in the cookies folder. The echo part > works fine. *See any problems? > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > strFolder = "c:\documents and settings\" > > Set objFolder = objFSO.GetFolder(strFolder) > > Set colFolders = objFolder.SubFolders > > * For Each objSubFolder In colFolders > *If objSubFolder.Path <> "C:\Documents and Settings\Default User" Or > objSubFolder.Path <> "C:\Documents and Settings\All Users" Or > objSubFolder.Path <> "C:\Documents and Settings\LocalService" Or > objSubFolder.Path <> "C:\Documents and Settings\NetworkService" Then > * objFSO.DeleteFile(objSubFolder.Path & "\Cookies\*.*") > *End If > *WScript.Echo objSubFolder.Path > * Next > > James > of your problem. I would suggest you try something more like this instead ... Set objFSO = CreateObject("Scripting.FileSystemObject") strFolder = "c:\documents and settings\" Set objFolder = objFSO.GetFolder(strFolder) Set colFolders = objFolder.SubFolders For Each objSubFolder In colFolders strPath = objSubFolder.Path & "\Cookies" If objFSO.FolderExists(strPath) then objFSO.DeleteFile strPath & "\*.*" End If WScript.Echo strPath Next _____________________ Tom Lavedas |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Get Folder Names You were right Tom. I fixed the If then logic and all is working great now. Thanks a ton for cathing that! James "Tom Lavedas" <tglbatch@xxxxxx> wrote in message news:a720f526-d196-4c83-92cf-007696e73f6a@xxxxxx On Aug 26, 4:44 pm, "James" <donotemai...@xxxxxx> wrote: Quote: > I am trying to delete all of the cookies files in everyone's user profile. > Here is what I found but I am getting an error that the path cannot be > found > when the code tries to delete the files in the cookies folder. The echo > part > works fine. See any problems? > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > strFolder = "c:\documents and settings\" > > Set objFolder = objFSO.GetFolder(strFolder) > > Set colFolders = objFolder.SubFolders > > For Each objSubFolder In colFolders > If objSubFolder.Path <> "C:\Documents and Settings\Default User" Or > objSubFolder.Path <> "C:\Documents and Settings\All Users" Or > objSubFolder.Path <> "C:\Documents and Settings\LocalService" Or > objSubFolder.Path <> "C:\Documents and Settings\NetworkService" Then > objFSO.DeleteFile(objSubFolder.Path & "\Cookies\*.*") > End If > WScript.Echo objSubFolder.Path > Next > > James > of your problem. I would suggest you try something more like this instead ... Set objFSO = CreateObject("Scripting.FileSystemObject") strFolder = "c:\documents and settings\" Set objFolder = objFSO.GetFolder(strFolder) Set colFolders = objFolder.SubFolders For Each objSubFolder In colFolders strPath = objSubFolder.Path & "\Cookies" If objFSO.FolderExists(strPath) then objFSO.DeleteFile strPath & "\*.*" End If WScript.Echo strPath Next _____________________ Tom Lavedas |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Folder names | Vista General | |||
| file names and folder names have been changed into some values automatically | Vista file management | |||
| Folder names | Vista mail | |||
| Folder names disappeared. | Vista General | |||
| hidden folder names | Vista file management | |||