Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

wnarretto

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
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!
martin

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?
StSiotis

Re: Check if file exists before download

Sorry i forgot to add my UserName before
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.
StSiotis

Check if file exists before download

Hello,
i want to check if a file exists before download it without using .NET assembly. I try this:
if exist c:\upload\test.txt winscp.com /script=upload.txt
from your documentation at https://winscp.net/eng/docs/guide_automation_conditional#scripting
but it returns an error that command if is not recognized. Could you help me plz?
Thank you!