Jump to content

Recommended Posts

Posted
Looking to get some data on files that have not been used in over three years and also report on what size file they are. Has anyone done anything similar?
Posted
Looking to get some data on files that have not been used in over three years and also report on what size file they are. Has anyone done anything similar?

 

Yes, just recently - our Windows 2003 didn't have Python available, so this is written in VBS:

 

Dim fso, folder, sFolder

Set fso = CreateObject("Scripting.FileSystemObject")

Function createSpacer(inputValue)
 if inputValue = 0 Then
   inputValueDiv = 1
 Else
   inputValueDiv = inputValue
 End If
 spacer = ""
 Do Until inputValueDiv >= 100000000000
   spacer = spacer & " "
   inputValueDiv = inputValueDiv * 10
 Loop
 createSpacer = spacer
End Function

Function listDir(path, folder, depth)
 Dim result
 Set result = CreateObject("Scripting.Dictionary")
 result.Add "totalSize", 0
 result.Add "lastModified", 0
 If depth <> 0 Then
   result.Item("lastModified") = folder.DateLastModified
 End If
 For each folderIdx In folder.Files
   filename = path & "\" & folderIdx.Name
   Set fileObject = fso.GetFile(filename)
   fileSize = fileObject.Size
   fileModified = fileObject.DateLastModified
   If fileModified > result.Item("lastModified") Then
     result.Item("lastModified") = fileModified
   End If
   wscript.echo(fileSize & createSpacer(fileSize) & fileModified & " " & fileName)
   result.Item("totalSize") = result.Item("totalSize") + fileSize
 Next

 For each folderIdx In folder.SubFolders
   If folderIdx.Name <> "System Volume Information" Then
     Set subFolderResult = listDir(path & "\" & folderIdx.Name, folderIdx, depth+1)
   End If
   wscript.echo(subFolderResult("totalSize") & createSpacer(subFolderResult("totalSize")) & subFolderResult.Item("lastModified") & " " & path & "\" & folderIdx.Name)
   result.Item("totalSize") = result.Item("totalSize") + subFolderResult.Item("totalSize")
 Next
 Set listDir = result
End Function




sFolder = wscript.Arguments.Item(0)
If sFolder = "" Then
   Wscript.Echo "No Folder parameter was passed"
   Wscript.Quit
End If

listDir sFolder, fso.GetFolder(sFolder + "\"), 0

Posted

What version of windows?

 

FSRM on 2008 gives you options to look at different attributes and then perform a task such as move them.

 

Ben

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...