Script - Check if file exists on local drive before downloading

Advertisement

Vanik
Guest

Script - Check if file exists on local drive before downloading

Hi,

Currently have a Batch file which downloads .CSV files from my SFTP to local file fine.
After handling the .CSV, it gets moved to a "processed" file.

I would ask if it is possible to add the the batch script which checks if the file exists locally in the "processed" file, before enable downloading from the SFTP site to the oringal file location.

Many thanks.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,378
Location:
Prague, Czechia

Re: Script - Check if file exists on local drive before downloading

Do I understand right, that you want to download a file only, if it does not exist already in a different folder than the download/destination folder?

There's no easy way to do this in WinSCP scripting.

But if you use WinSCP .NET assembly from a full-featured language, like PowerShell, it's trivial.

For some example, see:
https://winscp.net/eng/docs/library_example_check_existence_timestamp#powershell
You will just want to test the "processed" folder instead of the downloaded folder in the:
if (!(Test-Path $localPath))

Reply with quote

Advertisement

You can post new topics in this forum