Webmaster Forum

Go Back   Webmaster Forum > Scripting/Programming & Debugging > ASP & VBScript Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-31-2007, 08:54 PM
maltman maltman is offline
Junior Member
 
Join Date: Dec 2007
Posts: 1
maltman is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default Help deleting files in subfolders

Hey all,

I am new here and trying to get a script working for my company so we can delete files in subfolders. Here is a brief description of what it needs to do.

I have 4 subfolders

Folder
New-Folder
TempFolder1
TempFolder2

I am trying to delete everything older then 30 days in New-Folder.
Delete everything older then 90 days in the two temp folders (this will be about 40 folders on the server)
Do not delete anything in Folder (which will be 2 folders on our server)

Here is what I have so far:

Code:
NumberOfDaysOld = 30 NumberOfDaysOldTemp = 90 strPath = "C:\Documents and Settings\New Folder" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPath) Set colSubfolders = objFolder.Subfolders Set colFiles = objFolder.Files For Each objFile in colFiles If objFile.DateLastModified < (Date() - NumberOfDaysOld) Then objFile.Delete End If Next For Each objSubfolder in colSubfolders Set colFiles = objSubfolder.Files For Each objFile in colFiles If Left(objsubfolder.Name, 4) = "temp" AND objFile.DateLastModified < (Date() - NumberOfDaysOldTemp) Then objFile.Delete ElseIf Left(objsubfolder.Name, 6) = "folder" Then objFile.Delete = False ElseIf objFile.DateLastModified < (Date() - NumberOfDaysOld) Then objFile.Delete End If Next Next
The code works but it deletes everything 30 days old or older in all folders. Any help on this would be greatly appreciated.
Reply With Quote

This ad is part of our Revenue Sharing program
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
editing of txt files btb PHP Forum 1 10-11-2007 06:14 PM
Mid Function. Reading of files peachtea ASP & VBScript Forum 1 08-01-2007 01:33 AM


All times are GMT. The time now is 07:22 AM.


Creative Commons License
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30