Hello,

I'd like to automatically clean out files older than 90 days on a weekly
basis from specific directories are there any commands, utilities or
programs I can use to do this?


Thanks

Re: Any way to automatically delete old files from the FTP Directory? by Rick

Rick
Thu Jul 24 11:57:53 CDT 2008

www.quotasoft.com


"boe" <boe_d@hotmail.com> wrote in message
news:D9590A6D-05F3-48F5-9C3C-135507C6C264@microsoft.com...
> Hello,
>
> I'd like to automatically clean out files older than 90 days on a weekly
> basis from specific directories are there any commands, utilities or
> programs I can use to do this?
>
>
> Thanks


Re: Any way to automatically delete old files from the FTP Directory? by Rick

Rick
Thu Jul 24 11:58:04 CDT 2008

www.quotasoft.com


"boe" <boe_d@hotmail.com> wrote in message
news:D9590A6D-05F3-48F5-9C3C-135507C6C264@microsoft.com...
> Hello,
>
> I'd like to automatically clean out files older than 90 days on a weekly
> basis from specific directories are there any commands, utilities or
> programs I can use to do this?
>
>
> Thanks


Re: Any way to automatically delete old files from the FTP Directory? by Scooter

Scooter
Fri Jul 25 14:18:32 CDT 2008

Save this as "cleanup.vbs" or whatever, and run it nightly with your
systems schedular. You have to pass it a directory name. Also you'll
have to actually look at the code because you didn't specify 90 days
since last modified or 90 days since creation, which might be the same
for an ftp server. Its set to 90 days since creation. It will also
recurse through subdirectories if you uncomment the 3 lines near the
bottom. Probably not the most elegant vbs script in the world, but it
works. Oh and if you've never run vbscripts on your server before run
this first "cscript //H:cscript". Good luck.



If Wscript.Arguments.Count = 0 Then
Wscript.Echo "You need to tell me the directory"
Else
FileSearch Wscript.Arguments(0)
End If



Sub FileSearch(InDir)

Set fso = CreateObject("Scripting.FileSystemObject")
Set fileObject = fso.GetFolder(InDir)
Set fileCollection = fileObject.Files
Set subfoldersCollection = fileObject.SubFolders
For Each fInfo In fileCollection
thisFileName = InDir & "\" & fInfo.Name
wscript.echo thisFileName
Set thisFile = fso.GetFile(thisFileName)
createdate = thisFile.DateCreated
lastModifiedDate = thisFile.DateLastModified

' Do you want 90 days since creation, or 90 days since last modified?
Uncomment the line for what you want

intDaysOld = cInt(Date - CreateDate)
'intDaysOld = cInt(Date - lastModifiedDate)


If intDaysOld > 90 Then
wscript.echo thisFileName & " is " & intDaysOld & " days old.
Deleting!"
'fso.DeleteFile(thisFileName)
End If
Next

'' If you want it to go into subdirectories, uncomment below
'For Each fFolder In subfoldersCollection
' FileSearch (InDir & "\" & fFolder.Name)
'Next

End Sub

Re: Any way to automatically delete old files from the FTP Directory? by Scooter

Scooter
Mon Jul 28 11:30:16 CDT 2008

Oh and if you need to skip any particular extensions, here's an
update. You change "re.Pattern" to exclude the extensions you want to
skip, seperating each with a pipe symbol as in the example:

If Wscript.Arguments.Count = 0 Then
Wscript.Echo "You need to tell me the directory"
Else
FileSearch Wscript.Arguments(0)
End If



Sub FileSearch(InDir)

Set fso = CreateObject("Scripting.FileSystemObject")
Set fileObject = fso.GetFolder(InDir)
Set fileCollection = fileObject.Files
Set subfoldersCollection = fileObject.SubFolders

Set re = new regexp

For Each fInfo In fileCollection
thisFileName = InDir & "\" & fInfo.Name
wscript.echo thisFileName

re.IgnoreCase = true

' Add your extensions to skip here
re.Pattern = "config|cfg|dll|exe"

thisFileType = Right(thisFileName,Len(thisFileName)-
InStrRev(thisFileName,"."))
If re.Test(thisFileType) Then
'Skip This File
wscript.echo "Skipping " & thisFileName
Else
Set thisFile = fso.GetFile(thisFileName)
createdate = thisFile.DateCreated
lastModifiedDate = thisFile.DateLastModified

' Do you want 90 days since creation, or 90 days since last
modified?

'intDaysOld = cInt(Date - CreateDate)
intDaysOld = cInt(Date - lastModifiedDate)


If intDaysOld > 90 Then
wscript.echo thisFileName & " is " & intDaysOld & " days old.
Deleting!"
'fso.DeleteFile(thisFileName)
End If
End If
Next

'' If you want it to go into subdirectories, uncomment below
'For Each fFolder In subfoldersCollection
' FileSearch (InDir & "\" & fFolder.Name)
'Next

End Sub

Re: Any way to automatically delete old files from the FTP Directory? by boe

boe
Tue Jul 29 08:17:33 CDT 2008

Thank you

"Scooter" <slbentley@gmail.com> wrote in message
news:e348d63a-f554-4080-a8b4-456a62f19cb8@e53g2000hsa.googlegroups.com...
> Oh and if you need to skip any particular extensions, here's an
> update. You change "re.Pattern" to exclude the extensions you want to
> skip, seperating each with a pipe symbol as in the example:
>
> If Wscript.Arguments.Count = 0 Then
> Wscript.Echo "You need to tell me the directory"
> Else
> FileSearch Wscript.Arguments(0)
> End If
>
>
>
> Sub FileSearch(InDir)
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set fileObject = fso.GetFolder(InDir)
> Set fileCollection = fileObject.Files
> Set subfoldersCollection = fileObject.SubFolders
>
> Set re = new regexp
>
> For Each fInfo In fileCollection
> thisFileName = InDir & "\" & fInfo.Name
> wscript.echo thisFileName
>
> re.IgnoreCase = true
>
> ' Add your extensions to skip here
> re.Pattern = "config|cfg|dll|exe"
>
> thisFileType = Right(thisFileName,Len(thisFileName)-
> InStrRev(thisFileName,"."))
> If re.Test(thisFileType) Then
> 'Skip This File
> wscript.echo "Skipping " & thisFileName
> Else
> Set thisFile = fso.GetFile(thisFileName)
> createdate = thisFile.DateCreated
> lastModifiedDate = thisFile.DateLastModified
>
> ' Do you want 90 days since creation, or 90 days since last
> modified?
>
> 'intDaysOld = cInt(Date - CreateDate)
> intDaysOld = cInt(Date - lastModifiedDate)
>
>
> If intDaysOld > 90 Then
> wscript.echo thisFileName & " is " & intDaysOld & " days old.
> Deleting!"
> 'fso.DeleteFile(thisFileName)
> End If
> End If
> Next
>
> '' If you want it to go into subdirectories, uncomment below
> 'For Each fFolder In subfoldersCollection
> ' FileSearch (InDir & "\" & fFolder.Name)
> 'Next
>
> End Sub


Re: Any way to automatically delete old files from the FTP Directory? by boe

boe
Tue Jul 29 08:17:23 CDT 2008

Thanks

"Rick V" <rick@di-wave.com> wrote in message
news:71979B58-263E-4CA5-A366-44EBD71135B3@microsoft.com...
> www.quotasoft.com
>
>
> "boe" <boe_d@hotmail.com> wrote in message
> news:D9590A6D-05F3-48F5-9C3C-135507C6C264@microsoft.com...
>> Hello,
>>
>> I'd like to automatically clean out files older than 90 days on a weekly
>> basis from specific directories are there any commands, utilities or
>> programs I can use to do this?
>>
>>
>> Thanks
>