Jump to content

Script for deleting files older then


Recommended Posts

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.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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