Mushroomhead, вот Вам примерная болванка на WSH:
читать дальше »
Код:

Option Explicit
Dim strSourceFolder
Dim objRegExp
Dim dictPatternsAndDestFolders
Dim strComputer
Dim objSWbemLocator
Dim objSWbemServicesEx
Dim objSWbemEventSource
Dim objSWbemObjectEx
Dim strDestFolder
strSourceFolder = "C:\in"
Set objRegExp = WScript.CreateObject("VBScript.RegExp")
Set dictPatternsAndDestFolders = WScript.CreateObject("Scripting.Dictionary")
With dictPatternsAndDestFolders
.Add "^(6677|408)\d*$", "C:\in\1"
.Add "^(7788|40[^8])\d*$", "C:\in\2"
End With
strComputer = "."
Set objSWbemLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServicesEx = objSWbemLocator.ConnectServer(strComputer, "root\cimv2")
Set objSWbemEventSource = objSWbemServicesEx.ExecNotificationQuery( _
"SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE " & _
"TargetInstance ISA 'CIM_DirectoryContainsFile' AND " & _
"TargetInstance.GroupComponent = 'Win32_Directory.Name=""" & Replace(strSourceFolder, "\", "\\\\") & """'" _
)
WScript.Echo "Monitor files creation in [" & strSourceFolder & "]..."
Do
With objSWbemServicesEx.Get(objSWbemEventSource.NextEvent.TargetInstance.PartComponent)
WScript.Echo Now() & " | < | New file: [" & .Name & "]"
Select Case LCase(.Extension)
Case "xml"
strDestFolder = TestAndGetDestFolder(.Name)
If Not IsEmpty(strDestFolder) Then
If .Copy(strDestFolder & "\" & .FileName & "." & .Extension) = 0 Then
WScript.Echo Now() & " | > | Copy into: [" & strDestFolder & "]"
Else
WScript.Echo Now() & " | ! | Can't copy into: [" & strDestFolder & "]"
End If
End If
Case Else
' Nothing to do
End Select
If .Delete() = 0 Then
WScript.Echo Now() & " | v | Delete file: [" & .Name & "]"
Else
WScript.Echo Now() & " | ! | Can't delete file: [" & .Name & "]"
End If
End With
Loop
WScript.Quit 0
'=============================================================================
'=============================================================================
Function TestAndGetDestFolder(strFileName)
Dim strPattern
TestAndGetDestFolder = Empty
With WScript.CreateObject("Msxml2.DOMDocument")
If .load(strFileName) Then
With .selectSingleNode("/Файл/Документ/СвСчет/@НомСч")
For Each strPattern In dictPatternsAndDestFolders.Keys
objRegExp.Pattern = strPattern
If objRegExp.Test(.nodeValue) Then
TestAndGetDestFolder = dictPatternsAndDestFolders.Item(strPattern)
Exit For
End If
Next
End With
Else
WScript.Echo "Can't load xml content from [" & strFileName & "]."
End If
End With
End Function
'=============================================================================
Запускать под «cscript.exe».