批不适合循环监控,还是用vbs实现吧:- Dim SHELL, Path, Html
- Set SHELL = CreateObject("Wscript.Shell")
- Path = SHELL.CurrentDirectory
- Set SHELL = Nothing
- Do
- MoveFile Path
- WScript.Sleep 10000 '此为延迟10秒,请自行修改
- Loop
-
- Function MoveFile(Path)
- Dim FSO, SHELL, vbStr, File, Y, M, D, Str, arr
- vbStr = "<?xml version=""1.0"" encoding=""gbk"" ?>" & vbCrLf _
- & "<files>" & vbCrLf _
- & "@$#&" & vbCrLf _
- & "</files>"
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Html = ""
- If FSO.FileExists("List.xml") Then
- arr = Split(FSO.OpenTextFile("List.xml").ReadAll(), vbCrLf)
- For Each Str In arr
- If InStr(Str, "<file year=") Then Html = Html & Str & vbCrLf
- Next
- End If
- Str = ""
- For Each File In FSO.GetFolder(Path).Files
- If File.Name <> "List.xml" Then
- If LCase(FSO.GetExtensionName(File)) = "xml" Then
- Y = Year(Mid(File.Name, 1, 8))
- M = Month(Mid(File.Name, 1, 8))
- D = day(Mid(File.Name, 1, 8))
- Str = Str & "<file year=""" & Y & """month=""" & M & """day=""" & D & """name=""XXXX"" url=""服务器路径/A/" & File & """ />" & vbCrLf
- FSO.OpenTextFile("List.xml", 2, True).Write vbStr
- FSO.MoveFile File, Path & "\A\"
- End If
- End If
- Next
- vbStr = Replace(vbStr, "@$#&", Str & Html)
- Set FSO = Nothing
- End Function
复制代码
|