Come da oggetto...mi serve, data una cartella, avere l'elenco di tutti i file più vecchi di 30 minuti cercando anche in tutte le sottocartelle.
per farlo io uso questo script
codice:
StrDate2 = DateAdd("n", -30, Date)
PERC = "E:\MIACARTELLA"
Testo = ""
Tot = 0
StrDateOK2 = Year(StrDate2)
If Len(Month(StrDate2)) < 2 Then StrDateOK2 = StrDateOK2 & "0" & Month(StrDate2) Else StrDateOK2 = StrDateOK2 & Month(StrDate2)
If Len(Day(StrDate2)) < 2 Then StrDateOK2 = StrDateOK2 & "0" & Day(StrDate2) Else StrDateOK2 = StrDateOK2 & Day(StrDate2)
If Len(Hour(StrDate2)) < 2 Then StrDateOK2 = StrDateOK2 & "0" & Hour(StrDate2) Else StrDateOK2 = StrDateOK2 & Hour(StrDate2)
If Len(Minute(StrDate2)) < 2 Then StrDateOK2 = StrDateOK2 & "0" & Minute(StrDate2) Else StrDateOK2 = StrDateOK2 & Minute(StrDate2)
If Len(Second(StrDate2)) < 2 Then StrDateOK2 = StrDateOK2 & "0" & Second(StrDate2) Else StrDateOK2 = StrDateOK2 & Second(StrDate2)
StrDateOK2 = StrDateOK2 & ".000000+060"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strFolderName = PERC
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
arrFolderPath = Split(strFolderName, "\")
strNewPath = ""
For i = 1 to Ubound(arrFolderPath)
strNewPath = strNewPath & "\\" & arrFolderPath(i)
Next
strPath = strNewPath & "\\"
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile where Path = '" & strPath & "'")
For Each objFile in colFiles
Tot = Tot + 1
Testo = Testo & objFile.Name & "
"
Next
For Each objFolder in colSubfolders
GetSubFolders strFolderName
Next
Sub GetSubFolders(strFolderName)
Set colSubfolders2 = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder2 in colSubfolders2
strFolderName = objFolder2.Name
' Wscript.Echo "Nome Sottocartella:" & objFolder2.Name
arrFolderPath = Split(strFolderName, "\")
strNewPath = ""
For i = 1 to Ubound(arrFolderPath)
strNewPath = strNewPath & "\\" & arrFolderPath(i)
Next
strPath = strNewPath & "\\"
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile where Drive = 'E:' AND Path = '" & strPath & "' AND FileSize > '0' AND CreationDate < '"& StrDateOK2 &"'")
For Each objFile in colFiles
'Wscript.Echo "NomeFile 2 "& objFile.Name
Tot = Tot + 1
Testo = Testo & objFile.Name & "
"
Next
GetSubFolders strFolderName
Next
End Sub
if Tot > 0 then
WScript.StdOut.Write "scriptRes:Bad:"& Tot
Set objMail = CreateObject("CDO.Message")
objMail.From = "mittente@azienda.it"
objMail.To = "dest@azienda.it
objMail.Subject = "File Fermi su MIACARTELLA"
objMail.HtmlBody = Testo
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "217.169.111.37"
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMail.Configuration.Fields.Update
objMail.Send
else
WScript.StdOut.Write "scriptRes:Ok:"& Tot
end if
e per funzionare funziona.....ma ci mette davvero tanto (si trova a scorrere un FS di circa 500 Gb con migliaia di file tutti di passaggio).
esiste un metodo più veloce secondo voi??
bye