List Info

Thread: Delete Utility




Delete Utility
user name
2006-11-09 14:25:08

Spot on Ray, thanks that is exactly what I wanted!!

 

J

 


From: windows2000-bouncefreelists.org [mailto:windows2000-bouncefreelists.org] On Behalf Of Costanzo, Ray
Sent: 09 November 2006 14:06
To: windows2000freelists.org
Subject: [windows2000] Re: Delete Utility

 

Oops! ; The easy fix:

 

delzips.vbs:

Option Explicit

 

Const ROOT_PATH = "R:temp" 
Const NO_DELETE = "nodeldir"  ''name of directory to keep
Dim oFSO

 

Call Main()

 

Sub Main
 Set oFSO = CreateObject("Scripting.FileSystemObject")
 Call Delzips(oFSO.GetFolder(ROOT_PATH))
End Sub

 

Sub Delzips(dir)
 Dim oSubdir, oFile
 For Each oSubdir in dir.Subfolders
 ; Call Delzips(oSubdir)
 Next
 
 ;If dir.Name <> NO_DELETE Then 

 &nbsp;On Error Resume Next
 &nbsp;'oFSO.DeleteFile(oFSO.BuildPath(dir.Path, "*.zip"))

   On Error Goto 0
 &nbsp;WScript.Echo "Would delete " & oFSO.BuildPath(dir.Path, "*.zip")
&nbsp;End If
End Sub

 

Ray at work

-----Original Message-----
From: windows2000-bouncefreelists.org [mailto:windows2000-bouncefreelists.org] On Behalf Of Steve Rance
Sent: Thursday, November 09, 2006 9:03 AM
To: windows2000freelists.org
Subject: [windows2000] Re: Delete Utility

Ray,

 

Wow thanks for that…;it works on my test data too except if there is not a zip file in the directory it crashes out with a “File not found̶1; error message.&nbsp; Not sure how to fix it.

Thanks again Ray!!!

 

Steve

 


From: windows2000-bouncefreelists.org [mailto:windows2000-bouncefreelists.org] On Behalf Of Costanzo, Ray
Sent: 09 November 2006 13:02
To: windows2000freelists.org
Subject: [windows2000] Re: Delete Utility

 

Correction to script.&nbsp; This would NOT delete zips in a situation where there's a directory with your special name that contains a subdirectory that SHOULD have its zips deleted.&nbsp; Here is the corrected script:

 

delzips.vbs:

Option Explicit

 

Const ROOT_PATH = "R:temp"&nbsp;
Const NO_DELETE = "nodeldir"&nbsp; ''name of directory to keep
Dim oFSO

 

Call Main()

 

Sub Main
&nbsp;Set oFSO = CreateObject("Scripting.FileSystemObject")
 Call Delzips(oFSO.GetFolder(ROOT_PATH))
End Sub

 

Sub Delzips(dir)
&nbsp;Dim oSubdir, oFile
&nbsp;For Each oSubdir in dir.Subfolders
 ; Call Delzips(oSubdir)
&nbsp;Next
&nbsp;
 ;If dir.Name <> NO_DELETE Then
 &nbsp;'oFSO.DeleteFile(oFSO.BuildPath(dir.Path, "*.zip"))
  ;WScript.Echo "Would delete " & oFSO.BuildPath(dir.Path, "*.zip")
&nbsp;End If
End Sub

 

Ray at work

-----Original Message-----
From: windows2000-bouncefreelists.org [mailto:windows2000-bouncefreelists.org] On Behalf Of Ray Costanzo
Sent: Thursday, November 09, 2006 7:59 AM
To: windows2000freelists.org
Subject: [windows2000] Re: Delete Utility

Here, try this script.&nbsp; Register cscript as the default script handler so that the "wscript.echo&quot; lines don't attack you with a million messageboxes.  Notice that the line that would actually delete the files is commented out.  If it turns out this would work for you, just uncomment that line by deleting the apostrophe.

 

To register cscript, open a command prompt and enter:

cscript //h:cscript

 

delzips.vbs:

Option Explicit

 

Const ROOT_PATH = "R:temp"&nbsp;
Const NO_DELETE = "nodeldir"&nbsp; ''name of directory to keep
Dim oFSO

 

Call Main()

 

Sub Main
&nbsp;Set oFSO = CreateObject("Scripting.FileSystemObject")
 Call Delzips(oFSO.GetFolder(ROOT_PATH))
End Sub

 

Sub Delzips(dir)
&nbsp;Dim oSubdir, oFile
&nbsp;For Each oSubdir in dir.Subfolders
 ; If oSubdir.Name <> NO_DELETE Then Call Delzips(oSubdir)
&nbsp;Next
&nbsp;
 ;If dir.Name <> NO_DELETE Then
 &nbsp;'oFSO.DeleteFile(oFSO.BuildPath(dir.Path, "*.zip"))
  ;WScript.Echo "Would delete " & oFSO.BuildPath(dir.Path, "*.zip")
&nbsp;End If
End Sub

 

 

Here's the directory structure I tested it against.&nbsp; It worked as expected.

 

R:temp>dir /s /b
R:tempdelzips.vbs
R:tempdir1
R:tempdir2
R:tempdir3
R:tempdir4
R:tempzipdelete.cmd
R:tempdir1file.zip
R:tempdir1subdir1
R:tempdir1subdir2
R:tempdir1subdir3
R:tempdir1subdir1fil23.zip
R:tempdir1subdir1filaassd.zip
R:tempdir1subdir1filasd.zip
R:tempdir1subdir1file.zip
R:tempdir1subdir1file3.zip
R:tempdir1subdir1fsd.zip
R:tempdir1subdir2fil23.zip
R:tempdir1subdir2filaassd.zip
R:tempdir1subdir2filasd.zip
R:tempdir1subdir2file.zip
R:tempdir1subdir2file3.zip
R:tempdir1subdir2fsd.zip
R:tempdir1subdir3fil23.zip
R:tempdir1subdir3filaassd.zip
R:tempdir1subdir3filasd.zip
R:tempdir1subdir3file.zip
R:tempdir1subdir3file3.zip
R:tempdir1subdir3fsd.zip
R:tempdir2file.zip
R:tempdir2file2.zip
R:tempdir2subdir1
R:tempdir2subdir2
R:tempdir2subdir3
R:tempdir2subdir1fil23.zip
R:tempdir2subdir1filaassd.zip
R:tempdir2subdir1filasd.zip
R:tempdir2subdir1file.zip
R:tempdir2subdir1file3.zip
R:tempdir2subdir1fsd.zip
R:tempdir2subdir2fil23.zip
R:tempdir2subdir2filaassd.zip
R:tempdir2subdir2filasd.zip
R:tempdir2subdir2file.zip
R:tempdir2subdir2file3.zip
R:tempdir2subdir2fsd.zip
R:tempdir2subdir2nodeldir
R:tempdir2subdir2subsubdir1
R:tempdir2subdir2nodeldirfil23.zip
R:tempdir2subdir2nodeldirfilaassd.zip
R:tempdir2subdir2nodeldirfsd.zip
R:tempdir2subdir2subsubdir1filaassd.zip
R:tempdir2subdir2subsubdir1filasd.zip
R:tempdir2subdir2subsubdir1file.zip
R:tempdir2subdir2subsubdir1file3.zip
R:tempdir2subdir3fil23.zip
R:tempdir2subdir3filaassd.zip
R:tempdir2subdir3filasd.zip
R:tempdir2subdir3file.zip
R:tempdir2subdir3file3.zip
R:tempdir2subdir3fsd.zip
R:tempdir3fil23.zip
R:tempdir3filaassd.zip
R:tempdir3filasd.zip
R:tempdir3file.zip
R:tempdir3file3.zip
R:tempdir3fsd.zip
R:tempdir4fddile.zip
R:tempdir4fdile.zip
R:tempdir4fdirle.zip
R:tempdir4ffddile.zip
R:tempdir4file.zip
R:tempdir4subdir1
R:tempdir4subdir2
R:tempdir4subdir3
R:tempdir4subdir1fil23.zip
R:tempdir4subdir1filaassd.zip
R:tempdir4subdir1filasd.zip
R:tempdir4subdir1file.zip
R:tempdir4subdir1file3.zip
R:tempdir4subdir1fsd.zip
R:tempdir4subdir2fil23.zip
R:tempdir4subdir2filaassd.zip
R:tempdir4subdir2filasd.zip
R:tempdir4subdir2file.zip
R:tempdir4subdir2file3.zip
R:tempdir4subdir2fsd.zip
R:tempdir4subdir3fil23.zip
R:tempdir4subdir3filaassd.zip
R:tempdir4subdir3filasd.zip
R:tempdir4subdir3file.zip
R:tempdir4subdir3file3.zip
R:tempdir4subdir3fsd.zip

 

Ray at home

 

 


From: windows2000-bouncefreelists.org [mailto:windows2000-bouncefreelists.org] On Behalf Of Steve Rance
Sent: Thursday, November 09, 2006 7:35 AM
To: windows2000freelists.org
Subject: [windows2000] Re: Delete Utility

Thanks Ray, but we are talking hundreds of identically named folders that need excluding&#8230; I don’t fancy moving them then moving them back. ; I just though that as the delete functions built into Windows are very limited someone must have written a fancy delete utility.

 


From: windows2000-bouncefreelists.org [mailto:windows2000-bouncefreelists.org] On Behalf Of Ray Costanzo
Sent: 09 November 2006 12:12
To: windows2000freelists.org
Subject: [windows2000] Re: Delete Utility

 

Hi Steve,

 

If this is just a one time thing, what you could do is just do a search in Windows Explorer for the directory name that contains files you want to keep. ; After they're all displayed, cut and paste them above the root of the directory from which you want to start traversing and deleting.&nbsp; After they're safely moved, do a search for *.zip and delete all the results.&nbsp; Then move the directories back.

 

Ray at home

 


From: windows2000-bouncefreelists.org [mailto:windows2000-bouncefreelists.org] On Behalf Of Steve Rance
Sent: Thursday, November 09, 2006 6:37 AM
To: Windows2000freelists.org
Subject: [windows2000] Delete Utility

Hi Guys,

 

Anyone know of a freeware utility that allows mass deletion of files based on a criteria that will include exclusions of directories?

 

Basically, I need to delete over 50Gb of Zip files on one of our file servers with hundreds of deep directories, but exclude zip files within directories with a particular name (or which there will be hundreds).

 

I have just spent over an hour on google but didn’;t find anything that even came close to providing this functionality.

 

Thanks for any help.

 

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )