Cleared out: my mistake
Hi Martin,
sorry, found out the reason in full version of script!
Short answer: need to use delayed expansion, if you are in statements group
Long answer: after examining my original script
I've found out that all assignments in if exist "%source_mask%" ( ... ) block are not actual within the same block.
So I changed my piece of code in the following way:
and it worked! Sorry for disturbing...
sorry, found out the reason in full version of script!
Short answer: need to use delayed expansion, if you are in statements group
Long answer: after examining my original script
@echo off
set ftp_host=localhost
set ftp_user=u
set ftp_pass=p
set source_folder=C:\Temp
set source_pattern=*.txt
set winscp_root=winscp
set source_mask=%source_folder%\%source_pattern%
setlocal
if exist "%source_mask%" (
"%winscp_root%\winscp.com" /script=PutFiles.ftp > "%TEMP%\winscp.out"
if %ERRORLEVEL% EQU 0 (
echo Success
) else (
echo Problem while copying files
)
) else (
echo No files to upload
)
endlocal
I've found out that all assignments in if exist "%source_mask%" ( ... ) block are not actual within the same block.
So I changed my piece of code in the following way:
@echo off
set ftp_host=localhost
set ftp_user=u
set ftp_pass=p
set source_folder=C:\Temp
set source_pattern=*.txt
set winscp_root=winscp
set source_mask=%source_folder%\%source_pattern%
setlocal enabledelayedexpansion
if exist "%source_mask%" (
"%winscp_root%\winscp.com" /script=PutFiles.ftp > "%TEMP%\winscp.out"
if !ERRORLEVEL! EQU 0 (
echo Success
) else (
echo Problem while copying files
)
) else (
echo No files to upload
)
endlocal
and it worked! Sorry for disturbing...