Dim sOriginFolder, sDestinationFolder, sFile, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "C:\Reports"
sDestinationFolder = "\\10.10.10.100\Report"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
'msgbox(oFSO.GetExtensionName(sFile))
If UCASE(oFSO.GetExtensionName(sFile)) = "PDF" Then
oFSO.GetFile(sFile).Copy sDestinationFolder & "\" & oFSO.GetFileName(sFile),True
'Wscript.echo "Copying : " & Chr(34) & oFSO.GetFileName(sFile) & Chr(34) & " to " & sDestinationFolder)
End If
Next
In above i am copying only PDF files we can put wildcard or select multiple types. If we want to launch this operation we can call this vbs in a bat file and the bat file can be put in a "scheduled operation" which can RUN every X minutes/hours.
If you need to run on a specific condition like change of file etc please look here
http://blogs.technet.com/b/heyscriptingguy/archive/2004/10/11/how-can-i-automatically-run-a-script-any-time-a-file-is-added-to-a-folder.aspx
No comments:
Post a Comment