Link to home
Start Free TrialLog in
Avatar of flagshipcredit
flagshipcredit

asked on

Checking if file exists using WinSCP

I need to check if the EXTRmmDD.ZIP exists on the SFTP.

If it does, than put it in the C:\ziptest folder.

If it does not exist exit successfully.

I have attached my script that currently pulls the file down successfully if it already exists on the SFTP.
CheckIfFileExistsWINSCP.txt
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

on phone so will look back later... you may want to simplify your yesterday getting routine to two lines.  See some examples in my article here:

Will look back from pc later if I can.
https://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_1153-Using-dates-in-batch-files-scripts.html Steve
Avatar of flagshipcredit
flagshipcredit

ASKER

Do you know how I can check if the file exists?
Off hand I don't sorry.  The easiest way IMO would be to make it download into a known empty directory, then if a file exists in there it is the one you want.  If no file exists then it didn't need to run?  Is that a suitable option?
Slightly confused.  AS it stands, wouldn't you get the results you want.  WINSCP will try and transfer the file you are specifying, and if it exists will xfer it.  If it doesn't exist I expect WINSCP will error, but will not transfer any file.  Isn't that the result you wanted?

~bp
I need the file to check every 5 minutes. I do not want to get an email every 5 minutes saying the job failed.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial