Answer the question
In order to leave comments, you need to log in
How can I find out if a folder exists and take an action depending on the result?
I have a winscp synchronization script that works from a bat file
@echo off
del %APPDATA%\WinSCP\WinSCP.log
SET userfolder=foldername
SET server=/home/userfolder
"%APPDATA%\WinSCP\WinSCP.com" ^
/log="%APPDATA%\WinSCP\WinSCP.log" /ini=nul ^
/command ^
"open sftp://user:[email protected]/ -hostkey=*" ^
"cd %server%"^
"mkdir %userfolder%"^
"synchronize remote %APPDATA%\ViberPC %server%/%userfolder%/" ^
"exit"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
exit /b %WINSCP_RESULT%
Answer the question
In order to leave comments, you need to log in
https://winscp.net/forum/viewtopic.php?t=15867&sid...
You can set option batch continue before mkdir to ignore any errors and restore the option batch abort after.
Almost verbatim - the very first case of the syntax https://ss64.com/nt/if.html
test ! -d /var/backup/mysql/`date +%Y` && { mkdir -p /var/backup/mysql/`date +%Y` ; }
FILE=/etc/resolv.conf
if ; then
echo "$FILE exist"
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question