Hi All,
Below is a script I've been working with for some time - works very well. I need to modify it and am not sure how. Currently this will give me last modified of all files in all subdirectories. Simply enter the directory, enter where I want the output .txt to go and enter how many days back I want it to start listing. I need to add DateLastAccessed so the .txt lists full directory path\file, size, last modified and last accessed. I think it would make sense to keep the last modified logic the same so I can populate the .txt by that criteria and then add the DateLastAccessed to anything that "hits the radar".
Thanks for any assistance!
-Chris
Script>
Option Explicit
Dim oFSO, oFolder, sDirectoryPath, sStartPath, oFSO1, sReportName, fReport, oFldr
Dim oFileCollection, oFile, sDir
Dim iDaysOld
sStartPath = "H:\DIRECTORY"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFSO1 = CreateObject("Scripting.FileSystemObject")
sReportName = "C:\temp\DIRECTORY.txt"
Set fReport = oFSo1.CreateTextFile(sReportName, True)
fReport.WriteLine "File Path" & vbTab & "File Size" & vbTab & "Last Modified Date"
ListFolders(sStartPath)
Sub ListFolders(sDirectoryPath)
On Error Resume Next
iDaysOld = 731
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sDirectoryPath)
Set oFileCollection = oFolder.Files
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
fReport.write oFile & vbtab
fReport.write oFile.Size & vbtab
fReport.Write oFile.DateLastModified & vbnewline
End If
Next
For Each oFldr In oFolder.SubFolders
ListFolders oFldr.Path
Next
End Sub
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
Below is a script I've been working with for some time - works very well. I need to modify it and am not sure how. Currently this will give me last modified of all files in all subdirectories. Simply enter the directory, enter where I want the output .txt to go and enter how many days back I want it to start listing. I need to add DateLastAccessed so the .txt lists full directory path\file, size, last modified and last accessed. I think it would make sense to keep the last modified logic the same so I can populate the .txt by that criteria and then add the DateLastAccessed to anything that "hits the radar".
Thanks for any assistance!
-Chris
Script>
Option Explicit
Dim oFSO, oFolder, sDirectoryPath, sStartPath, oFSO1, sReportName, fReport, oFldr
Dim oFileCollection, oFile, sDir
Dim iDaysOld
sStartPath = "H:\DIRECTORY"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFSO1 = CreateObject("Scripting.FileSystemObject")
sReportName = "C:\temp\DIRECTORY.txt"
Set fReport = oFSo1.CreateTextFile(sReportName, True)
fReport.WriteLine "File Path" & vbTab & "File Size" & vbTab & "Last Modified Date"
ListFolders(sStartPath)
Sub ListFolders(sDirectoryPath)
On Error Resume Next
iDaysOld = 731
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sDirectoryPath)
Set oFileCollection = oFolder.Files
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
fReport.write oFile & vbtab
fReport.write oFile.Size & vbtab
fReport.Write oFile.DateLastModified & vbnewline
End If
Next
For Each oFldr In oFolder.SubFolders
ListFolders oFldr.Path
Next
End Sub
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing