You can set "option batch continue" before mkdir and reset it to "option batch on" afterwards.
I'm writing a winscp script. How do I check to see if a folder exists? I need to create the folder if it doesn't exist. In most cases, the folder will already exists, but when it doesn't, I need to create it.
So I'm using the mkdir command. But this reports an error if it attempts to create the folder and it already exists. I returning the resulting status to a batch file so I can report success or failure, so I don't want the error.
Here is the script:
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
open user:password@server.com
# Force binary mode transfer
option transfer binary
option synchdelete on
# Change remote directory
cd /home/user/web
# Upload the file to current remote directory
put data.tss
# Make remote directory if it doesn't exist
mkdir /home/user/web/data-Web
# Change remote directory
cd /home/user/web/data-Web
# Change local directory
lcd data-Web
# Synchronize remote with local
synchronize remote
# Disconnect
close
# Exit WinSCP
exit
I sure wish I could "pause" at the end too so that I can review the session before the window closes.
Thanks!