I want to find if a file exists at FTP using if-exist filename -else statement using FTP batch script which is as follows:
ftp.txt open ftp.mysite.com
ftp.txt username
ftp.txt password
ftp.txt if exist filename (echo file exists) else (echo file doesn't exist)
ftp.txt quit
ftp -s:ftp.txt
the if-exist line above does not work. Is there any other way to search?
Don't do the logic in the FTP script.
Call the ftp.txt script from a batch file. Within your ftp.txt script, just do a GET on your file. If the file is there, it'll be downloaded to the local directory. Otherwise, it won't. After calling the FTP script, check the file's existence in your local directory using standard DOS batch commands, i.e.:
If you want to build a delay into your retries, perform a "sleep" by pinging a bogus IP address, as described in this post: http://www.dullsharpness.com/2010/06/14/elapsed-timer-using-pure-ms-dos/