"speedstic" wrote:
> what I would like the script to eventually do, is scan all files in a certain
> folder (including subfolders) and if the file has not been modified in 1
> year, then copy the file to a new location before deleting it, while writing
> to a txt file which files have been moved, their size, and the number of
> files moved.
> I haven't been able to move forward since i can't seem to get this part
> working.
If you want to use VBScript and WMI for this you need to use a recursive
function. Here is a sample:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Call ListFiles ("C:\scripts")
'*************************************************
Sub ListFiles (strFolderName)
Set ChildItemList = objWMIService.ExecQuery _
("Associators Of {Win32_Directory.Name=""" _
& Replace (strFolderName, "\", "\\") _
& """} Where Role = GroupComponent")
For Each objItem in ChildItemList
If objItem.Path_.Class = "Win32_Directory" Then
Call ListFiles (objItem.Name)
WScript.Echo "Folder" & objItem.Name
ElseIf objItem.Path_.Class = "CIM_DataFile" Then
WScript.Echo "File " & objItem.Name
End If
Next
End Sub
There is also a sample here, maybe you can use it:
http://www.microsoft.com/technet/scr...5/hey0405.mspx
Is there a reason you want to use WMI for this? The command line option does
look simpler.
--
urkec
Bookmarks