PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Re: Finding files older than 2 weeks old
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: Finding files older than 2 weeks old

Réponse
 
LinkBack Outils de la discussion
Vieux 12/11/2007, 19h33   #1
McKirahan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Finding files older than 2 weeks old

Sorry for the last blank post.

"mharmon" <mharmon@discussions.microsoft.com> wrote in message
news:F3A9BFF0-A0FF-494A-A8BF-2C6B01B01903@microsoft.com...
> I want to write a script that will look through a folder and subfolder and
> find all files of a particular file extension that are over 2 weeks old

and
> write these files to a log.
> Then run weekly from Windows Scheduler.


Write the files (i.e. their contents) or filenames to a log file?
If the former then hopefully it's not binary data. What extension?


  Réponse avec citation
Vieux 12/11/2007, 19h50   #2
McKirahan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Finding files older than 2 weeks old

"McKirahan" <News@McKirahan.com> wrote in message
news:Q5CdnaM7BIDTAaXanZ2dnUVZ_sOrnZ2d@comcast.com. ..
> Sorry for the last blank post.
>
> "mharmon" <mharmon@discussions.microsoft.com> wrote in message
> news:F3A9BFF0-A0FF-494A-A8BF-2C6B01B01903@microsoft.com...
> > I want to write a script that will look through a folder and subfolder

and
> > find all files of a particular file extension that are over 2 weeks old

> and
> > write these files to a log.
> > Then run weekly from Windows Scheduler.

>
> Write the files (i.e. their contents) or filenames to a log file?
> If the former then hopefully it's not binary data. What extension?



Will this ? Watch for word-wrap.

This write the full path of files older than "cDAZ" to a log file.
Modify the value of "cFOL" to your folder.
Modify the value of "cTXT" to your extension.


Option Explicit
'*
'* Declare Constants
'*
Const cVBS = "oldfiles.vbs"
Const cLOG = "oldfiles.log"
Const cFOL = "D:\Temp"
Const cEXT = ".txt"
Const cDAZ = 14
'*
'* Declare Variables
'*
Dim strDIR
strDIR = WScript.ScriptFullName
strDIR = Left(strDIR,InStrRev(strDIR,"\"))
Dim dtmDLM
Dim arrFIL()
Dim intFIL
intFIL = 0
Dim strFIL
Dim strFOL
Dim dtmNOW
dtmNOW = Now
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objGFI
Dim objOTF
Set objOTF = objFSO.OpenTextFile(strDIR & cLOG,2,True)
'*
'* GetFilesFolders()
'*
If objFSO.FolderExists(cFOL) Then
Call GetFilesFolders(cFOL)
For intFIL = 0 To UBound(arrFIL)
objOTF.WriteLine arrFIL(intFIL)
Next
End If
'*
'* Destroy Objects
'*
Set objOTF = Nothing
Set objFSO = Nothing
'*
'* Newset File
'*
WScript.Echo intFIL & " files older than " & cDAZ & " days."

Sub GetFilesFolders(folder)
'*
'* Get Files
'*
For Each strFIL In objFSO.GetFolder(folder).Files
If LCase(Right(strFIL.Name,Len(cEXT))) = cEXT Then
Set objGFI = objFSO.GetFile(folder & "\" & strFIL.Name)
dtmDLM = objGFI.DateLastModified
Set objGFI = Nothing
If DateDiff("d",dtmDLM,dtmNOW) > cDAZ Then
ReDim Preserve arrFIL(intFIL)
arrFIL(intFIL) = folder & "\" & strFIL.Name
intFIL = intFIL + 1
End If
End If
Next
'*
'* Get Subfolders
'*
For Each strFOL In objFSO.GetFolder(folder).SubFolders
Call GetFilesFolders(strFOL.Path)
Next
End Sub


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h08.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10656 seconds with 10 queries