Jump to content

Recommended Posts

Posted

Hi.

I need script in *.bat which will do the deletion of files, older tnen for example 10 days. I have one vbs, which i found on the internet.

Dim Fso
Dim Directory
Dim Modified
Dim Files

Set Fso = CreateObject("Scripting.FileSystemObject")

ListFolderContents("E:\Backup")

Sub ListFolderContents(path)
Set fs = CreateObject("Scripting.FileSystemObject")
Set folder = fs.GetFolder(path)
For each item in folder.SubFolders
DeleteFiles(item.Path)
Next
Set folder = Nothing
set fs = Nothing
End Sub

Sub DeleteFiles(Dir)
Set Directory = Fso.GetFolder(Dir)
Set Files = Directory.Files
For Each Modified In Files
If DateDiff("D", Modified.DateLastModified, Now) < 1 Then Modified.Delete
Next

End Sub

This code is not working, i dont know why? Have anyone simple *bat file or can anyone mode this script.

Tnx.


Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...