MSFN Forum: Script for deleting files older then - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Script for deleting files older then Rate Topic: -----

#1 User is offline   lincolnnavigator 

  • Group: Members
  • Posts: 1
  • Joined: 30-July 09

Posted 30 July 2009 - 06:17 AM

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.


#2 User is offline   jcarle 

  • MSFN Master
  • Group: Developers
  • Posts: 2,569
  • Joined: 14-August 04

Posted 01 August 2009 - 12:19 AM

That's not a batch file, that a VBScript file. Change your file extension to .vbs.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy