|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"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 |
|
![]() |
| Outils de la discussion | |
|
|