Mr. Roboto

Old and In the Way

Tired of wading through old folders in your file servers? Check out this script.

Most network administrators have a few file servers that are dumping grounds for old folders and files that no one knows where to keep. These servers often have files created years ago. Does this sound like you?

Most of you probably have some sort of process to manage this type of situation. If you're using Windows 2003 R2, it has an excellent file-server management tool. If you're using another operating system or don't have any utility to keep track of old files, though, Mr. Roboto is here to pull a tool from his scripting utility belt to help out.

I've assembled a simple VBScript called FileAgeReporter.vbs. Give the script a path and it will analyze every file in every folder and subfolder. The script will prepare a report in comma-delimited text format showing the file name, its size, the date it was created, the date it was last modified, the date it was last accessed, its file extension, its file type and its owner. When it's finished, you can open the file in Microsoft Excel for further sorting and filtering.

Even though the script will gather the last-accessed date, don't rely on this as an absolute indication of the last time a user actually accessed the file. Anti-virus scanners and disk defraggers can affect this date. I've included this date in the script for the sake of thoroughness, but I wouldn't consider it unfailingly accurate.

Besides the Excel file, the script will also prepare a text-file report with an analysis of file aging. The report will also list every file type found, the number of files, the percentage of total files, the total size and the percentage of total size.

File Aging Analysis
[Click on image for larger view.]

Admins Only
You'll have to run this script from a command prompt using CScript.exe. You'll also need to run it with administrator credentials: cscript FileAge Reporter.vbs /folder:path [/norecurse] [/owner] [/verbose] [/?]

The only required property is the path. This can be a local drive, folder, networked drive or a UNC path. It uses the path to automatically generate report file names. The script takes the path name, removes the colons and replaces \ with _. It converts the path to uppercase and appends a timestamp so that checking folder c:\files\public, for example, will result in file C_FILES_ PUBLIC_20070611214328.csv. The report files are saved to the same directory as the script, though you can edit the script.

By default, the script will search recursively through all subfolders from the specified path. You can override this behavior with the /norecurse parameter: cscript FileAgeReporter.vbs /folder:D:\Files\Sales /norecurse. The parameter in that example will give you a set of reports for the Sales folder only.

Roboto on Demand

Download Mr. Roboto's FileAgeReporter at www.jdhitsolutions.com/scripts.

What Windows admin task would you like Mr. Roboto to automate next? Send your suggestions to [email protected].

Assuming the folder or path is formatted in NTFS, you can also get the owner of each file. This feature requires Windows Management Instrumentation (WMI), so the file server must be running some version of Windows. Depending on the number of files to process, adding owner information will slow down script performance. To add owner information use the /owner parameter: cscript FileAge Reporter.vbs /folder:D:\Files /owner.

You can download the FileAgeReporter from my Web site. It should give you some valuable information on how the file store is growing in your file servers and how long certain items have been there. This can help you make better storage-management decisions.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

Featured

comments powered by Disqus

Subscribe on YouTube