Автор: Hugo121
Дата сообщения: 08.12.2009 15:10
Я свой код подправил, обрабатывает папку с скриптом:
Код:
Dim FSO
Dim TheFolder, TheFiles, AFile
Dim objFolder
Dim sep, nov, dec
on error resume next'иначе выкидывает ошибки после перемещения
Set FSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
MyPath = left (WScript.ScriptFullName, (Len(WScript.ScriptFullName))-(Len(WScript.ScriptName)))
MyPathShort = Left(MyPath, Len(MyPath)-1)
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & MyPathShort & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder in colSubfolders
if mid(objFolder.Name, 12, 2) = "09" Then sep = objFolder.Name ' : msgbox "OK: " & objFolder.Name ': msgbox "september: " & sep
if mid(objFolder.Name, 12, 2) = "11" Then nov = objFolder.Name
if mid(objFolder.Name, 12, 2) = "12" Then dec = objFolder.Name
'msgbox "objFolder Name: " & objFolder.Name '
Next
Set TheFolder = FSO.GetFolder(MyPath) 'Каталог, где смотреть
Set TheFiles = TheFolder.Files
For Each AFile In TheFiles
If UCase(FSO.GetExtensionName(AFile.Path)) = "MSG" then
'msgbox FSO.GetFile(AFile.Path).DateLastModified
if sep <> "" then : If mid((FSO.GetFile(AFile.Path).DateLastModified),4, 2) = "09" Then FSO.MoveFile AFile.Path , sep & "\"
if nov <> "" then : If mid((FSO.GetFile(AFile.Path).DateLastModified),4, 2) = "11" Then FSO.MoveFile AFile.Path , nov & "\"
if dec <> "" then : If mid((FSO.GetFile(AFile.Path).DateLastModified),4, 2) = "12" Then FSO.MoveFile AFile.Path , dec & "\"
end if
next