基本代码:由 Ekkehard.Horner 编写并由我改编我找到了代码,谢谢大家。调暗 oShell、频率、sFile 调暗 goFS :设置 goFS = CreateObject("Scripting.FileSystemObject") 调暗 oSrcDir :设置 oSrcDir = goFS.GetFolder("C:\Temp1") 调暗 sDstDir :sDstDir = "C:\Temp2" 调暗 oFile , nInc, sNFSpec
Set oShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\Temp1")
Set fc = f.Files
frequency = 10 * 1000
Const cnMax = 99
WScript.Sleep frequency
theDate = Year(Now()) _
& Right(String(2,"0") & month(Now()),2) _
& Right(String(2,"0") & Day(Now()),2)
For Each f1 in fc
If right(lcase(f1.name),4) = ".pdf" then
theBaseName = fso.GetBaseName(f1.name)
theExtension = fso.GetExtensionName(f1.Name)
f1.Move(fso.GetParentFolderName(f1.path) & "\" & theBaseName & "_" & EID & "_" & theDate & "." & theExtension)
End If
Next
For Each oFile In oSrcDir.Files
If right(lcase(oFile.name),4) = ".pdf" Then
nInc = 0
sNFSpec = getNewFSpec(oFile.Name, sDstDir, nInc)
Do While goFS.FileExists(sNFSpec) And nInc <= cnMax
sNFSpec = getNewFSpec(oFile.Name, sDstDir, nInc)
Loop
If nInc > cnMax Then
Else
oFile.Move sNFSpec
End If
End If
Next
Wend
}
Dim oShell, frequency, sFile
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
Dim oSrcDir : Set oSrcDir = goFS.GetFolder("C:\Temp1")
Dim sDstDir : sDstDir = "C:\Temp2"
Dim oFile, nInc, sNFSpec
Set oShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\Temp1")
Set fc = f.Files
frequency = 10 * 1000
Const cnMax = 99
WScript.Sleep frequency
theDate = Year(Now()) _
& Right(String(2,"0") & month(Now()),2) _
& Right(String(2,"0") & Day(Now()),2)
For Each f1 in fc
If right(lcase(f1.name),4) = ".pdf" then
theBaseName = fso.GetBaseName(f1.name)
theExtension = fso.GetExtensionName(f1.Name)
f1.Move(fso.GetParentFolderName(f1.path) & "\" & theBaseName & "_" & EID & "_" & theDate & "." & theExtension)
End If
Next
For Each oFile In oSrcDir.Files
If right(lcase(oFile.name),4) = ".pdf" Then
nInc = 0
sNFSpec = getNewFSpec(oFile.Name, sDstDir, nInc)
Do While goFS.FileExists(sNFSpec) And nInc <= cnMax
sNFSpec = getNewFSpec(oFile.Name, sDstDir, nInc)
Loop
If nInc > cnMax Then
Else
oFile.Move sNFSpec
End If
End If
Next
Wend
}