cancel
Showing results for 
Search instead for 
Did you mean: 

Delete old files

Former Member
0 Kudos

Hello,

In usual when I create scenarios with file (Inbound or outbound) I sand backup file to backup folder.

I'm looking for easy way to create scenarios or something else that clean the backup folders.

I'm looking for process that clean the older files, for example I want to erase all the files that older then 3 month.

Do you have any idea?

Regards

Elad

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

I found a script for that:

'***************************************************************************************************

'*

'* File: fdel.vbs

'* Created: June-2006

'* Version: 1.0

'*

'*

'*

'* Main Function: Check "DateCreated" of specific files and if difference between Now time

'* pass the Time limit and delete old files

'*

'*

'* Usage: WSCRIPT.EXE fmon.vbs [Path to Directory with old files] [Time limit in days]

'*

'* Example: WSCRIPT.EXE fmon.vbs C:\Windows\Temp 7

'*

'****************************************************************************************************

Dim objExCmd, fso, Time_Out_Before_Action, Base_dir, filename1

On error resume next

Set WshShell = WScript.CreateObject( "WScript.Shell" )

Set fso = CreateObject("Scripting.FileSystemObject")

Set objArgs = Wscript.Arguments

Const ForReading = 1, ForWriting = 2

For intI = 0 To Wscript.Arguments.Count - 1

next

Base_dir = Wscript.Arguments.item(I)

Time_Out_Before_Action = Int(Wscript.Arguments.item(I+1))

'**** Getting list of files *****

'Set objExCmd = WshShell.Exec("cmd /c echo off"&Chr(38)&"for /f "&Chr(34)&"tokens=* delims=. "&Chr(34)&" %a in ('dir "&Chr(34)&Base_dir&Chr(34)&" /b') do echo %a")

Set objExCmd = WshShell.Exec("cmd /c echo off"&Chr(38)&"dir "&Chr(34)&Base_dir&Chr(34)&" /b")

Do until objExCmd.StdOut.AtEndOfStream

filename1 = objExCmd.StdOut.ReadLine

If DateDiff("d", fso.GetFile(Base_dir&"\"&filename1).DateCreated, Now) > Time_Out_Before_Action Then

'MsgBox filename1&"; Diff="&DateDiff("d", fso.GetFile(Base_dir&"\"&filename1).DateCreated, Now)&"> time ="&Time_Out_Before_Action

f = fso.DeleteFile(Base_dir&"\"&filename1,true)

End If

Loop

Regards

Elad

Former Member
0 Kudos

I guess you can achieve through scripts.

Create a shell script which will delete files that are older than 3 months and call this script from your communication channel.

Regards,

Jai Shankar