Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
on error resume Next
Dim obj_FSO
Dim char_Dir
Dim obj_Folder
Dim obj_FileColl
Dim obj_File
Dim obj_ArcFile1
Dim int_DaysOld
Dim char_date
int_DaysOld = 7 'age in days
char_Dir = "C:\yourdir\here" 'target dir
char_date = Year(Now) & Right("0" & Month(Now),2) & Right("0" & Day(Now),2)
Set obj_FSO = CreateObject("Scripting.FileSystemObject")
Set obj_Folder = obj_FSO.GetFolder(char_Dir)
Set obj_FileColl = obj_Folder.Files
Set obj_ArcFile1 = obj_FSO.CreateTextFile("c:\yourdir\logdir\DelFile1_" & char_date & ".txt", True)
'DateLastModified is what is shown via explorer in windose
'can also use DateCreated and DateLastAccessed based upon needs
For each obj_File in obj_FileColl
If DateDiff("d", obj_File.DateLastModified,Now ()) > int_DaysOld Then
obj_ArcFile1.WriteLine(obj_File & " " & obj_File.DateLastModified & " Deleted")
obj_File.Delete(True)
End If
Next
obj_ArcFile1.Close
'clear objects
Set obj_FSO = Nothing
Set obj_Folder = Nothing
Set obj_FileColl = Nothing
Set obj_File = Nothing
Set obj_ArcFile1 = Nothing
'First, you will need to setup a scheduled task and run it
'daily. Just change the iDaysOld number to the amount of days you
'want to keep file in that directory. Any files in the
'directory will be deleted. This file must be place WITHIN
'the directory you wish to clean.
'Courtesty of monsterjta @ tek-tips.com
'Start
Option Explicit
on error resume next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld
Dim CurDir
'Definitions
iDaysOld = 5
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = CreateObject("WScript.Shell").CurrentDirectory
sDirectoryPath = sDirectory & "\"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
'Walk through each file in this folder collection.
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
'End