How to obtain a report on stale directories

Posted on 2012-09-17
Last Modified: 2012-09-18
We'd like to get a report on home directories that have not had any of their contents updated in over 120 days. These directories are all on the same Windows server and NTFS volume. Does anyone know how to do this?
Question by:tshearon
    LVL 1

    Expert Comment

    I often use sfk command line utility for such stuff. If you are on the server, in the root directory containing all user home directories, type the following all in one line (or a batch file):
    sfk list -nosub -justdirs . +run -quiet "sfk list -nohead -late=1 -tabs $qfile" -yes | sfk filter -replace "_\*__" +sort -reverse

    Open in new window

    Explanation: list all dir names of current directory. run a command on every dir name to list the most recent file showing date and absolute filename. change every filename to just the home folder path. sort all by date in reverse order.

    This will create a tab separated list with date, time, and folder name, sorted with oldest home folders at list bottom.
    LVL 51

    Accepted Solution

    Here's a fairly simple VBS script that should do the job.  You may want to tweak the output format.  Save as a VBS, and then run passing it two parms, the base folder name, and the number of days of age to report.  For example:

    cscript //nologo EE27867622.vbs c:\temp 200

    if you want to save the output to a file then do:

    cscript //nologo EE27867622.vbs c:\temp 200 > report.txt

    ' Get folder name to scan from command line
    If (WScript.Arguments.Count > 0) Then
      strDir = WScript.Arguments(0)
      WScript.Echo "No base folder name specified."
    End If
    ' Get days old to display from command line
    If (WScript.Arguments.Count > 1) Then
      intDays = CInt(WScript.Arguments(1))
      WScript.Echo "Missing age (days) to report."
    End If
    ' Create file system object
    Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    ' Access the base folder specified
    Set objFolder = objFSO.GetFolder(strDir)
    ' Look at all subfolders and display of they meet the age criteria
    For Each objSubFolder In objFolder.Subfolders
       If DateDiff("d", objSubFolder.DateLastModified, Now) > intDays Then 
          Wscript.Echo "Folder:[" & objSubFolder.Path & "], Age:[" & DateDiff("d", objSubFolder.DateLastModified, Now) & "] days"
       End If

    Open in new window

    LVL 8

    Author Closing Comment

    Thanks billprew. This is exactly what I wanted.
    LVL 51

    Expert Comment

    by:Bill Prew
    Great, glad that helped.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now