old file delete - 2 December 2009 - Blog - AHMET BOGUS ELECO TEST DRIVE
Tuesday
06.December.2016
12:10
Login form
Search ARAMA
Calendar TAKVIM
«  December 2009  »
SuMoTuWeThFrSa
  12345
6789101112
13141516171819
20212223242526
2728293031
Entries archive
Oy Havuzu
BU SEZON KIM SAMPIYON OLUR KI?
Total of answers: 109
Dost Siteler
  • Kendine Bir site Hazırla
  • Statistics

    Total online: 1
    Guests: 1
    Users: 0

    TEST ELECO

    Blog

    Main » 2009 » December » 2 » old file delete
    old file delete
    15:58

    Here is a script to delete old files (let's say 15 day old files.) This script will help in clearing old files and some run time generated log files which may increase in size (MB) over a period of time.
    This script can either be used with Scheduled within the Normal Scheduled Tasks or Deployment Server Script job.
    Changes that need to be made while using this script in your environment are: Specify Directory Path from where you want to clear the old files in the following line of code in the main script.
    sDirectoryPath = "C:\MyFolder" Specify Number of days old file to delete in the following Line of code in the main script.
    iDaysOld = 15 Specify the extension of file that you want to delete and the number with number of character in the file extension in the following Line of code in the main script.
    If LCase(Right(Cstr(oFile.Name), 3)) = "txt" Then '************ Start of Code ********************** Option Explicit On Error Resume Next Dim oFSO, oFolder, sDirectoryPath Dim oFileCollection, oFile, sDir Dim iDaysOld ' Specify Directory Path From Where You want to clear the old files sDirectoryPath = "C:\MyFolder" ' Specify Number of Days Old File to Delete iDaysOld = 15 Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(sDirectoryPath) Set oFileCollection = oFolder.Files For each oFile in oFileCollection 'This section will filter the log file as I have used for for test case 'Specify the Extension of file that you want to delete 'and the number with Number of character in the file extension If LCase(Right(Cstr(oFile.Name), 3)) = "log" Then If oFile.DateLastModified < (Date() - iDaysOld) Then oFile.Delete(True) End If End If Next Set oFSO = Nothing Set oFolder = Nothing Set oFileCollection = Nothing Set oFile = Nothing '**************** End of Code *******************
    Views: 378 | Added by: ahmetbogus | Rating: 0.0/0 |
    Total comments: 0
    Name *:
    Email *:
    Code *: