Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
zagix
- Posts: 68
- Joined: 16 Oct 2013 23:19
#1
Post
by zagix » 16 Mar 2014 16:13
Hello,
I have placed the file name to download from ftp server in an external file at c:\list.txt. Is it possible for the ftp batch file to fetch the file name from c:\list.txt for mget.
File name in list.txt (17 Mar 2014) only 1 name.
Code: Select all
>>file.tmp echo open xxx.xxx.xx.x
>>file.tmp echo username
>>file.tmp echo password
>>file.tmp echo lcd d:\received
>>file.tmp echo cd /download
>>file.tmp echo binary
>>file.tmp echo mget =============> [c:\list.txt]
>>file.tmp echo disconnect
>>file.tmp echo bye
:loop
ftp -i -s:"file.tmp"
if not exist "d:\received\=============> [c:\list.txt]" (
timeout /t 30 /nobreak
goto :loop
)
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#3
Post
by foxidrive » 16 Mar 2014 21:01
This may help if the list is more than one filespec.
Code: Select all
@echo off
>>file.tmp echo open xxx.xxx.xx.x
>>file.tmp echo username
>>file.tmp echo password
>>file.tmp echo lcd d:\received
>>file.tmp echo cd /download
>>file.tmp echo binary
FOR /F "delims=" %%a in (C:\list.txt) do (
>>file.tmp echo mget %%a
)
>>file.tmp echo disconnect
>>file.tmp echo bye
:loop
ftp -i -s:"file.tmp"
FOR /F "delims=" %%a in (C:\list.txt) do (
if not exist "d:\received\%%a" (
timeout /t 30 /nobreak
goto :loop
))
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 16 Mar 2014 21:15
I do not see a reason for a 30 second delay for checking if the file is there or not. Your ftp happens first. The IF exist will not execute until the ftp is done. Why wait 30 seconds to execute the next command?
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#5
Post
by foxidrive » 16 Mar 2014 21:16
if the FTP server link failed it could give the modem etc time to acquire the connection again.
-
zagix
- Posts: 68
- Joined: 16 Oct 2013 23:19
#6
Post
by zagix » 19 Mar 2014 21:18
Hello,
Thanks for helping.
Thanks