correction for upload of all files in a txt file to ftp

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alwayssmiling007
Posts: 4
Joined: 01 Sep 2011 03:38

correction for upload of all files in a txt file to ftp

#1 Post by alwayssmiling007 » 03 Sep 2011 02:42

I have managed to edit the below code which will upload all the said files whoes links are stored in a text file. But the problem is that the below code only upload 10 to 15 files... all other files it skips. Can anyone please help me to fix this problem ?

@Echo Off
Setlocal Enabledelayedexpansion

Set "FtpCommand=mput"
For /F "Delims=" %%A In (filelist.txt) Do (
Call Set "FtpCommand=%%FtpCommand%% "%%~A""
)
Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\%~n0.ftp"
rem Notepad "%temp%\%~n0.ftp"

For %%A In (%FtpCommand%) Do Echo.%%A

REM -- Execute Ftp Script, download files
ftp -i -s:"%temp%\%~n0.ftp"
Del "%temp%\%~n0.ftp"
GOTO:EOF

:extractFileSection StartMark EndMark FileName -- extract a section of file that is defined by a start and end mark
:: -- [IN] StartMark - start mark, use '...:S' mark to allow variable substitution
:: -- [IN,OPT] EndMark - optional end mark, default is first empty line
:: -- [IN,OPT] FileName - optional source file, default is THIS file
:$created 20080219 :$changed 20100205 :$categories ReadFile
:$source http://www.dostips.com
SETLOCAL Disabledelayedexpansion
set "bmk=%~1"
set "emk=%~2"
set "src=%~3"
set "bExtr="
set "bSubs="
if "%src%"=="" set src=%~f0& rem if no source file then assume THIS file
for /f "tokens=1,* delims=]" %%A in ('find /n /v "" "%src%"') do (
if /i "%%B"=="%emk%" set "bExtr="&set "bSubs="
if defined bExtr if defined bSubs (call echo.%%B) ELSE (echo.%%B)
if /i "%%B"=="%bmk%" set "bExtr=Y"
if /i "%%B"=="%bmk%:S" set "bExtr=Y"&set "bSubs=Y"
)
EXIT /b

[Ftp Script 1]:S
!Title Connecting...
open ftpserver.com
username
password

!Title Preparing...
cd anydirectoy
lcd c:\MyLocalDirectory
binary
hash

!Title Processing... %FtpCommand%
%FtpCommand%

!Title Disconnecting...
disconnect
bye

Post Reply