Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete "New Folder" vbscript

Status
Not open for further replies.

czchrn7k

MIS
Aug 7, 2004
31
0
0
US
Folks...I need a script to delete all "New Folders" on the c drive..no matter where it exists....New Folder..New Folder(1)..New Folder(2)....OR..

C:\data\files\New Folder\papers\New Folder....etc.

I want this to search through all sub-directories too..currently what I have searches only the c:\ and not the sub-directories...

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name Like '%c:\\New Folder%'")

For Each objFolder in colFolders
objFolder.delete
Next
 
Search this forum for these terms:

Recursion
Recurse
Recursive

You should find plenty of examples.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top