ftp batch running commands before @ftp

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Bessime
Posts: 1
Joined: 25 Sep 2017 16:11

ftp batch running commands before @ftp

#1 Post by Bessime » 25 Sep 2017 17:15

Hi,

So I am wanting to make a small batch file that will delete, rename and pack some files using winrar then upload the new file using ftp.

Code: Select all

cd D:\test
del test02.rar
rename test01.rar test02.rar
rar.exe a D:/test/test01.rar c:/test/test/ -hppassword -rr5p -tk -dh -m3
@ftp -i -s:"%~f0"&GOTO:EOF
open ftp.test.com
user
password
binary
mput D:\test\test01.rar
bye



the issue I'm having is that when it runs the @ftp line it starts over and tries to run the "cd D:\test" and the rest of the lines as ftp commands so getting some error messages that the right command isnt being run, it still works but was looking at cleaning it up so it doesn't keep throwing up errors. It is important to me that the batch file stays as a single file so would like to avoid using a txt file to keep the ftp information separate.

thank you and any help would be appreciated.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: ftp batch running commands before @ftp

#2 Post by penpen » 25 Sep 2017 18:39

You could either append at characters ('@') in front of each batch command to prevent it beeing recognized as a ftp command:

Code: Select all

@cd D:\test
@del test02.rar
@rename test01.rar test02.rar
@rar.exe a D:/test/test01.rar c:/test/test/ -hppassword -rr5p -tk -dh -m3
@ftp -i -s:"%~f0"&GOTO:EOF
open ftp.test.com
user
password
binary
mput D:\test\test01.rar
bye

Or you could do it this way (which i prefer):
http://www.dostips.com/forum/viewtopic.php?f=3&t=4941&start=15#p28817.


penpen

Post Reply