Using If ... Else within a Batch file - FTP Script
Posted: 15 Jun 2011 03:08
Hi all,
I've got a batch which creates a script to run against FTP, which counts the number of .csv files in a given directory. If the count is correct the batch will create a file (.done)
What i would like to do is add an ELSE statement after this. So if :count: < 10 (for example) DO :this command:
As i've no experience of using the ELSE command in DOS, could anyone give me some pointers?
Many Thanks,
Andy
I've got a batch which creates a script to run against FTP, which counts the number of .csv files in a given directory. If the count is correct the batch will create a file (.done)
What i would like to do is add an ELSE statement after this. So if :count: < 10 (for example) DO :this command:
Code: Select all
> c:\test2\script2.txt echo open ******
>> c:\test2\script2.txt echo *****
>> c:\test2\script2.txt echo *****
>> c:\test2\script2.txt echo cd ***
>> c:\test2\script2.txt echo cd ***
>> c:\test2\script2.txt echo cd ***
>> c:\test2\script2.txt echo SETLOCAL
>> c:\test2\script2.txt echo SETLOCAL ENABLEDELAYEDEXPANSION
>> c:\test2\script2.txt echo SET count=0
>> c:\test2\script2.txt echo for %%o IN ("\\*****\****\****\****\*.csv") DO (
>> c:\test2\script2.txt echo %%o
>> c:\test2\script2.txt echo SET /A count=count + 1
>> c:\test2\script2.txt echo )
>> c:\test2\script2.txt echo echo %count%
>> c:\test2\script2.txt echo IF "%count%"=="10" ECHO Done >> "\\******\*****\***\****\****.done" I WOULD LIKE TO ADD 'ELSE' HERE
>> c:\test2\script2.txt echo ENDLOCAL ENABLEDELAYEDEXPANSION
>> c:\test2\script2.txt echo ENDLOCAL
>> c:\test2\script2.txt echo bye
start /w ftp.exe -s:c:\test2\script2.txt
del c:\test2\script2.txt
As i've no experience of using the ELSE command in DOS, could anyone give me some pointers?
Many Thanks,
Andy