Check if file exists before download

Advertisement

Advertisement

Guest

Re: Check if file exists before download

I don't want to use .NET assembly. I have mentioned that in question! I want to use a simple bat file.

Reply with quote

martin
Site Admin
martin avatar

Re: Check if file exists before download

OK, I've misunderstood the question.

Though it's still confusing. Why are you trying to check a local file before calling WinSCP with upload.txt script, if you are going to download a file?

Reply with quote

Advertisement

StSiotis

Re: Check if file exists before download

i use get command to download a file from a server...But everytime the file doesn't exists i get an error message. So i want to firstly check if the file exists and then use get command to download it!

Reply with quote

wnarretto
Guest

script for checking if file exists is not working

hello-
so the situation is to check that a file exists first, if it does then continue on to the next steps of the ssis package. if the file does not exist then exit and stop. i used the script from https://winscp.net/eng/docs/script_checking_file_existence#scripting and when i run it i get an error message...
Script: set REMOTE_PATH=/Home/blahblahblah/CustomContractImport/Import/Importcontract.xlsx
Script: Unknown command 'set'.
Script: Failed
is this set command not right? is there something that was not in the original script that was not correct? this seems like a simple script even for a noob like me but apparently it is not. :( can someone help me?
the scriopt is...
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect to SFTP server using a password
open sftp://blipblahbloop:EQFz7I:igL13@transfer.filecheck.com/ -hostkey="ssh-rsa 2048 fc:0f:92:5d:98:d4:77:65:2a:eb:a2:fa:0d:27:0a:7f"
# Upload file

echo off
 
set REMOTE_PATH=/Home/blahblahblah/CustomContractImport/Import/Importcontract.xlsx
winscp.com /command ^
    "open mysession" ^
    "stat %REMOTE_PATH%" ^
    "exit"
 
if %ERRORLEVEL% neq 0 goto error
 
echo File %REMOTE_PATH% exists

exit /b 0
 
:error
echo Error or file %REMOTE_PATH% not exists
exit /b 1


# Disconnect
close

Reply with quote

Advertisement

You can post new topics in this forum