I am trayng to create a package on SSIS where the last step is to delete files older than 7 days.
I found an article here with the code to create it (http://qa.sqlservercentral.com/articles/Administering/usingvbscripttoautomatetasks/1171/)
But I am new to SSIS and also to VBS and do not know how to modify it so it can be used on the script task. can any one help ??
Here is the script
Option Explicit
on error resume next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld
'Customize values here to fit your needs
iDaysOld = 7
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "C:\test"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
'Walk through each file in this folder collection.
'If it is older than (7) days, then delete it.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next
'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing