TommyTupa
asked on
Batch process to delete folers and bypass recycle bin on WinNT
I have a batch file to delete folders on a WindowsNT Server shown at the end of this question. My problem is that the folders I'm deleting are 26GB. Is there any way to bypass the recycle bin while deleting?
Here's the function I'm using right now:
Private Function fDeleteFolders(BackupPath, TSO)
Dim FSO
Dim Folders
Dim Folder
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
Set Folders = FSO.GetFolder(BackupPath)
For Each Folder In Folders.subFolders
If DateDiff("d", Folder.DateCreated, Date) < 10 Then
TSO.Write "Deleted: " & Folder.Name & vbCrLf
Folder.Delete True
fDeleteFolders = "true"
End If
Next
Set Folder = Nothing
Set Folders = Nothing
End Function
Thanks, TT
Here's the function I'm using right now:
Private Function fDeleteFolders(BackupPath,
Dim FSO
Dim Folders
Dim Folder
Set FSO = CreateObject("Scripting.Fi
Set Folders = FSO.GetFolder(BackupPath)
For Each Folder In Folders.subFolders
If DateDiff("d", Folder.DateCreated, Date) < 10 Then
TSO.Write "Deleted: " & Folder.Name & vbCrLf
Folder.Delete True
fDeleteFolders = "true"
End If
Next
Set Folder = Nothing
Set Folders = Nothing
End Function
Thanks, TT
Why don't you use a simple CMD file with the delete command, so in that way you don't put the files in recicle bin.
ASKER
I need to delete folders older than x number of days. Didn't think this can be done with CMD.
Instead of rewriting your already fine batch file change the way your recycle bin works. Use gpedit.msc go to User Configuration, Administrative Template, Windows Explorer, open Maximum Allowed Recycle Bin Size. Enable the policy and input a number between 0 and 100% to represent the amount of disk your recycle bin is allowed to take up, all other files will be permanently deleted.
FlyBoy97
FlyBoy97
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This can be done with a CMD file, but it gets a little complex in determining what the date was 90 day ago. There are also difficulties in dealing with different date and time formats that are used at the system level.
I would recommend you find a better way of dealing with the recycle bin or use the VBS to enumerate the files that need to be deleted and then call the shell to do DEL /Q /F %path%\%filename%.
I would recommend you find a better way of dealing with the recycle bin or use the VBS to enumerate the files that need to be deleted and then call the shell to do DEL /Q /F %path%\%filename%.
ASKER
I really appreciate everyone's input. I'll do some testing later this week and follow up.