MS-DOS to FTP from a remote server and copy files to a local folder


I need to write a single dos script which will first FTP from a remote server to my local directory and then will copy these files to another folder within the local machine. The reason behind the second step is that the destination folder path is based on whether the SYSTEM Processor of 32-bit or 64-bit.

I have two separate scripts which are working fine now. But when I am putting them together in a single script, it is failing with the ftp command prompt. Here is the script which I am using -

@echo off



rmdir c:\batch\temp

mkdir c:\batch\temp

goto :ftpbegin


@ftp -i -s:"%~f0"&GOTO:EOF
open x.y.z.a
!:-----FTP commands here -----
lcd C:\batch\temp
cd CGServices\Uploads
mget "*.psl"
mget "*.PST"
mget "*.psy"
get abc.ini
get def.pmd


exit /b


if %winver% ==x86 (goto :copywin32) else (goto :copywin64)


echo "inside copywin32"

<do the copy files here>

<do copy files here>

exit /b 0

However, the ftp script seems to cause a break while executing the second part of my program since it is calling the program in a loop in ftp prompt. So, none of the dos commands are translated on FTP prompt.

Any help on how to achieve this in a single script for this is highly appreciated.

thanks, Sanders

The FTP command AFAIK cannot process the commands from the command line without reading the ftp commands from an external file. I usually download a windows version of wget, and it works well for us, perhaps you would like to have a look at that.

Here is the manual for wget

for example

wget ftp://<user>:<password>