DOS Batch FTP - Simple - FTP script and batch in a single file
Embed FTP script into a batch script. Add this line at the beginning of the FTP script:
@ftp -i -s:”%~f0″&GOTO:EOF
The “FTP -s:ftpscript.txt” option executes a FTP script wheres “%~f0″ resolved to the name of the running batch file. “GOTO:EOF” ends the batch script and makes sure the FTP script doesn`t run as part of the batch.
Good: You end up with only one file that contains the batch script and the FTP script combined.
Minor flaw: The batch command in the first line causes an “Invalid command.” error when executed in FTP context, however the FTP execution will continue.
@ftp -i -s:”%~f0″&GOTO:EOF
open example.com
username
password
!:— FTP commands below here —
lcd c:\MyLocalDirectory
cd public_html/MyRemoteDirectory
binary
mput “*.*”
disconnect
bye