• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

FTP a folder from command line

J
#1
Hi,

I need to transfer a folder structure (recursively) to a remote ftp
server from a script in my win2008 server. I've tried using mput but it
does not seem to work.

Thanks for an example copying C:\MyStuff (all subfolders and files) to
192.168.12.1 by ftp from the commandline.

Thanks a lot :-)

regards

jake
 

My Computer

P

Pegasus [MVP]

#2
"Jake" <jake44@newsgroup> wrote in message
news:eiiCnk7YKHA.2160@newsgroup

> Hi,
>
> I need to transfer a folder structure (recursively) to a remote ftp server
> from a script in my win2008 server. I've tried using mput but it does not
> seem to work.
>
> Thanks for an example copying C:\MyStuff (all subfolders and files) to
> 192.168.12.1 by ftp from the commandline.
>
> Thanks a lot :-)
>
> regards
>
> jake
Let's have a look at your script that did not quite work!
 

My Computer

J
#3
Pegasus [MVP] skrev:

> Let's have a look at your script that did not quite work!
In the file ftpscriptfull-1.txt below I have tried various options:
C:\DirWithSubfolders
C:\DirWithSubfolders\
C:\DirWithSubfolders\*.*

Contents of file ftpscriptfull-1.txt:

user moses <passwrd>
mput C:\DirWithSubfolders
bye

Contents of actual batch file:

ftp -n -s:c:\bogus\ftpscriptfull-1.txt 192.168.100.13
echo Full file copy completed at %time% - %date% >> C:\bogus\log.txt

I want to copy C:\DirWithSubfolders with all its files and subfolders.

regards jake
 

My Computer

P

Pegasus [MVP]

#4
"Jake" <jake44@newsgroup> wrote in message
news:%23LbyhOEZKHA.4920@newsgroup

> Pegasus [MVP] skrev:

>> Let's have a look at your script that did not quite work!
>
> In the file ftpscriptfull-1.txt below I have tried various options:
> C:\DirWithSubfolders
> C:\DirWithSubfolders\
> C:\DirWithSubfolders\*.*
>
> Contents of file ftpscriptfull-1.txt:
>
> user moses <passwrd>
> mput C:\DirWithSubfolders
> bye
>
> Contents of actual batch file:
>
> ftp -n -s:c:\bogus\ftpscriptfull-1.txt 192.168.100.13
> echo Full file copy completed at %time% - %date% >> C:\bogus\log.txt
>
> I want to copy C:\DirWithSubfolders with all its files and subfolders.
>
> regards jake
Ftp.exe is a fairly primitive program. To compensate for its lack of
sophistication, you have to add some intelligence to the batch file that
invokes it, e.g. like so:

@echo off
set Source=d\Friday
if not %Source:~1,2%==:\ (
echo You must specify a fully qualified source folder, e.g. D:\My Files
pause
goto :eof
)
call :Sub %Source%
for /F "delims=" %%a in ('dir "%Source%" /ad /b /s') do call :Sub %%a
goto :eof

:Sub
set Folder=%*
set Folder=%Folder:~3%
set Folder=%Folder:\=/%
echo Copying files from "%*" to "%Folder%"

set script=c:\script.scr
set site=www.MySite.com
set account=JakeKlefbeck
set password=Lisa

echo> %script% %account%
echo>>%script% %password%
echo>>%script% binary
echo>>%script% prompt off
echo>>%script% cd usr/home/jake
echo>>%script% mkdir "%Folder%"
echo>>%script% cd "%Folder%"
echo>>%script% mput "%*\*.*"
echo>>%script% quit
ftp -s:%script% %site%
del %script%
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)