VBScript that sees if a file exists in a folder?
Posted on 2004-10-13
I have put together a script that when launched will move a specific file from user machine to a server. The script works. However, I would like to add some logic that looks for any file with an extension of .csv in a folder and if found then move that file.
Currently, it is hard coded (strFilePath) to move a specific filename. Some of my code is below:
strFilePath = "C:\MyProjects\EPIBS7AA.csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Delete file if it already exists in the destination(server).
If (objFSO.FileExists("Z:\EPIBS7AA.csv")) then
WshShell.PopUp "File deleted."
If (objFSO.FileExists(strFilePath)) then
' Move the file to destination
Set objFileCopy = objFSO.GetFile(strFilePath)
WSCript.Echo "Moved to " & RemotePath
WshShell.PopUp "File Not Found in " & strFilePath
Any help would be greatly appreciated. Thanks