Jump to content

scotimus

Members
  • Posts

    1
  • Joined

  • Last visited

Reputation

0 Neutral

About scotimus

Personal Information

  • Occupation
    Sys Admin
  • Location
    Virginia Beach

Employer (optional)

  • Company Represented
    Portfolio Recovery & Assoc.
  1. I currently have a script that I run a task for weekly to delete log files. I need to modify it to delete all folders and their contents within a certain directory that are over 2 days old. I cant quite figure it out. Any help would be appreciated. This is what I use for the file deletion: ' SET THE DROPDATE VARIABLE TO TODAYS DATE MINUS 30 DAYS dropdate = dateadd("d", -30, date()) ' CREATE A FILESYSTEM OBJECT set fso = createobject("scripting.filesystemobject") ' CREATE A FOLDER OBJECT (USING THE FILESYSTEM OBJECT) set folders = fso.getfolder("C:\WINDOWS\system32\LogFiles\W3SVC1") ' CREATE A FILES OBJECT (USING THE FOLDER OBJECT THAT'S USING THE FILESYSTEM OBJECT.) set files = folders.files ' LOOP THROUGH EACH FILENAME IN THE FILES OBJECT for each file in files ' COMPARE THE FILES 'DATE LAST MODIFIED' PROPERTY ' IF THE FILES 'DATE LAST MODIFIED' IS MORE THAN DROPDATE, THEN ECHO SOME OUTPUT AND DELETE THE FILE if file.datelastmodified < dropdate then 'wscript.echo folders.path & "\" & file.name & " last modified: " & file.datelastmodified file.delete on error resume next end if next
×
×
  • Create New...