Jared Luker
asked on
Utility or script to scan a share and report on file ages
I need a utility that can scan a folder recursively and report on the modified dates of the files.
I have a share that is creeping up on 4TB that our product development team uses. I want to trim that WAY down or buy more SAN storage, so I need to know how many files are > 1 year old, > 2 years old, etc.
Thanks
I have a share that is creeping up on 4TB that our product development team uses. I want to trim that WAY down or buy more SAN storage, so I need to know how many files are > 1 year old, > 2 years old, etc.
Thanks
robocopy.exe (included since Windows 2008/Vista, Resource Kit Tools for W2k3: http://www.microsoft.com/en-us/download/details.aspx?id=17657) can do this:
With the "/L" robocopy will just pretend to copy, without actually doing anything. The total size will be listed in the summary at the end. You can even add a minimum size using /MIN:<minimum file size in bytes>.
With /tee /log:"<Log file>", you can write to a log file as well as the console.
robocopy "D:\Share" "D:\Dummy" *.* /s /np /minage:365 /r:0 /L
The target folder should NOT exist.With the "/L" robocopy will just pretend to copy, without actually doing anything. The total size will be listed in the summary at the end. You can even add a minimum size using /MIN:<minimum file size in bytes>.
With /tee /log:"<Log file>", you can write to a log file as well as the console.
Here's a VBS that I did for a similar question. Just run it from a command line and pipe the output to a CSV file, then open in Excel and you can manipulate it there.
cscript //nologo EE28185045.vbs \\computer1\share1 > report.csv
cscript //nologo EE28185045.vbs \\computer1\share1 > report.csv
' Set up filesystem object for usage
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Get folder name to list off the command line, make sure it's valid
If (WScript.Arguments.Count > 0) Then
strFolder = Wscript.Arguments(0)
If Not objFSO.FolderExists(strFolder) Then
WScript.StdErr.WriteLine "Specified folder does not exist."
WScript.Quit
End If
Else
WScript.StdErr.WriteLine "No folder name specified to list."
WScript.Quit
End If
' Get access to the folder we want to list files in
Set objFolder = objFSO.GetFolder(strFolder)
' Header line
WScript.StdOut.WriteLine Quote("Path") & "," & Quote("File Name") & "," & Quote("File Size") & "," & Quote("Last Accessed") & "," & Quote("Last Modified")
' Look for files
FindFiles objFolder
Sub FindFiles(objFolder)
On Error Resume Next
' List files
For Each objFile In objFolder.Files
On Error Resume Next
If Err.Number <> 0 Then ShowError "FindFiles:01", objFolder.Path
On Error Resume Next
WScript.StdOut.WriteLine Quote(objFile.ParentFolder) & "," & Quote(objFile.Name) & "," & objFile.Size & "," & Quote(objFile.DateLastAccessed) & "," & Quote(objFile.DateLastModified)
If Err.Number <> 0 Then ShowError "FindFiles:02", objFile.Path
Next
If Err.Number = 0 Then
' Recursively drill down into subfolder
For Each objSubFolder In objFolder.SubFolders
On Error Resume Next
If Err.Number <> 0 Then ShowError "FindFiles:04", objFolder.Path
FindFiles objSubFolder
If Err.Number <> 0 Then ShowError "FindFiles:05", objSubFolder.Path
Next
Else
ShowError "FindFiles:03", objFolder.Path
End If
End Sub
' Add surrounding double quotes to a string
Function Quote(s)
Quote = Chr(34) & s & Chr(34)
End Function
Sub ShowError(strLocation, strMessage)
WScript.StdErr.WriteLine "==> ERROR at [" & strLocation & "]"
WScript.StdErr.WriteLine " Number:[" & Err.Number & "], Source:[" & Err.Source & "], Desc:[" & Err.Description & "]"
WScript.StdErr.WriteLine " " & strMessage
Err.Clear
End Sub
~bp
And if you want to use Powershell it's pretty simple there, with a command like:
get-childitem C:\temp -rec | where {!$_.PSIsContainer} | select-object FullName, LastWriteTime, Length | export-csv -notypeinformation -delimiter '|' -path file.csv
~bp
I need a utility that can scan a folder recursively and report on the modified dates of the files.Are you sure the modified date is going to help you? What if it is simply read often?
My two favorite tools for this are windirstat and sequoiaview. They are both very similar in showing the disk space used etc. I like the sequoiaview because it allows you to filter on date, modified, file type, etc. Lots of options.
http://windirstat.info/
http://w3.win.tue.nl/nl/onderzoek/onderzoek_informatica/visualization/sequoiaview//
http://windirstat.info/
http://w3.win.tue.nl/nl/onderzoek/onderzoek_informatica/visualization/sequoiaview//
ASKER
obda: Robocopy has shown the most promise of the solutions so far because it does a good job of sumarizing the data. I don't need to necessiarily SEE every file that has not been modified between X and Y dates. I'm mostly concerned with the amount of space they are taking up.
BillPrew: Could you narrow that down to files that have NOT been modified since a certain date? So, just for an example, I'm looking for a list of files and their sizes that have a modified date older than say 7/15/2011. If the total size could be calculated, it would be pretty cool, but I know that would probably be Excel's job in this instance.
CEHJ: I guess that's a good question. if the file is accessed at all, it would be good to know, but I didn't know of any way of determining that.
xxdcmast: I have used WinDirStat extensively and love it, but neither it nor SequoiaView do what I want in this case. it will show you files that have been modified between x and y dates. I need files that have NOT been modified. Again, I'm looking for information on stale data.
BillPrew: Could you narrow that down to files that have NOT been modified since a certain date? So, just for an example, I'm looking for a list of files and their sizes that have a modified date older than say 7/15/2011. If the total size could be calculated, it would be pretty cool, but I know that would probably be Excel's job in this instance.
CEHJ: I guess that's a good question. if the file is accessed at all, it would be good to know, but I didn't know of any way of determining that.
xxdcmast: I have used WinDirStat extensively and love it, but neither it nor SequoiaView do what I want in this case. it will show you files that have been modified between x and y dates. I need files that have NOT been modified. Again, I'm looking for information on stale data.
If you're not interested in robocopy's file or folder list, just add "/nfl" (No File List) and "/ndl" (No Directory List) to the options. You can even suppress the header as well with /njh (No Job Header).
Instead of filtering for last change, robocopy could check for the "last accessed" time stamp as well using "/minlad:365" instead of "/minage:365".
Jus be aware that the "Last Access" time has been disabled by default since Vista/Server 2008, and it isn't that terribly reliable anyway, because it can be updated by other software (backup, Antivirus software), without a user having actually opened the file.
Fsutil behavior
http://technet.microsoft.com/en-us/library/cc785435(v=ws.10).aspx
Registry Settings that can be Modified to Improve Operating System Performance
http://msdn.microsoft.com/en-us/library/ee377058(v=bts.10).aspx
Instead of filtering for last change, robocopy could check for the "last accessed" time stamp as well using "/minlad:365" instead of "/minage:365".
Jus be aware that the "Last Access" time has been disabled by default since Vista/Server 2008, and it isn't that terribly reliable anyway, because it can be updated by other software (backup, Antivirus software), without a user having actually opened the file.
Fsutil behavior
http://technet.microsoft.com/en-us/library/cc785435(v=ws.10).aspx
Registry Settings that can be Modified to Improve Operating System Performance
http://msdn.microsoft.com/en-us/library/ee377058(v=bts.10).aspx
Jus be aware that the "Last Access" time has been disabled by default since Vista/Server 2008, and it isn't that terribly reliable anyway, because it can be updated by other software (backup, Antivirus software), without a user having actually opened the file.
That might be the case, but bear in mind that the last modified timestamp could be even less reliable as to how important a file is. Worth checking the status of last access stamp:
http://www.pctools.com/guides/registry/detail/50/
BillPrew: Could you narrow that down to files that have NOT been modified since a certain date? So, just for an example, I'm looking for a list of files and their sizes that have a modified date older than say 7/15/2011. If the total size could be calculated, it would be pretty cool, but I know that would probably be Excel's job in this instance.Yes. Which script were you referring to, the VBS or PS1?
Do you want to check just the last update date, or do you want to check both the last update date and the last read date, and only consider files that have not been read or updated since the specified date.
~bp
ASKER
billprew..
The PowerShell is much more efficient, so I'd go with that. I think that I'm OK with the last modified date for what I'm doing here.
Obda:
Thanks for the additional robocopy info.
The PowerShell is much more efficient, so I'd go with that. I think that I'm OK with the last modified date for what I'm doing here.
Obda:
Thanks for the additional robocopy info.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER