1

I have a simple script to move perform some maintenance operations on the remote Unix SFTP host, but would like to do all of the operations only if some of the files exist on the windows server. Here is example of the simple code I use, and was wondering if WinSCP supports "if exist " windows command:

option batch abort
option confirm off
open sftp://[email protected] -hostkey="xxxxxx" - privatekey=\\location

delete file.txt

rename file1.txt

put file0.txt file.txt

etc...

exit

Would be nice to do all of the above if I could do something like this:

if exist (\\windows server\filename.txt
    .....
)

Have to mention that execution is performed using WinSCP.com.

1
  • Can you use an actual batch file to call the winscp script file? There is definitely a batch-file command to check for existence of a file. Commented Oct 17, 2014 at 22:19

1 Answer 1

1

As @Ian suggested in comments, you do not need the if-then logic in the WinSCP script for this. Just use the if command in wrapper batch file like:

@echo off
if exist \\windows_server\filename.txt winscp.com /script=script.txt

Had you really needed to use if-then logic in WinSCP code, see WinSCP article Conditional Processing in Automation.

Further reading:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.