homepage Welcome to WebmasterWorld Guest from 184.73.40.21
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft Windows OS (XP/NT/Vista/Windows 7/8/9/10)
Forum Library, Charter, Moderators: bill

Microsoft Windows OS (XP/NT/Vista/Windows 7/8/9/10) Forum

    
trying to ftp entire directory using dos bat commands
drooh

5+ Year Member



 
Msg#: 3677371 posted 7:17 pm on Jun 14, 2008 (gmt 0)

I am trying to set up a scheduled windows task that will execute a .bat file every so often. This .bat file will connect using ftp to a given web server. From there I would like it to download the entire directory I specify (public_html) and keep all the folders intact, maintaining heirarchy. After this I have it zippping everything up wiht the dat first followed by the name of the root folder.

The problem I am having is that it will download all the files but will not maintain the folders, instead it calls them uknown file and just makes them a file with no extension.

Here is what I have so far.

this is the ftp.bat file

C:\WINDOWS\system32\ftp.exe -i -s:ftp.txt

lcd C:\ftp\backup

"C:\Program Files\7-Zip\7z.exe" a -tzip %date:~10%-%date:~4,2%-%date:~7,2%_somewebsite.com.zip @listfile.txt

del C:\ftp\backup /Q

Here is the contents of ftp.txt

open ftp.somewebsite.com
username123
password456
ls
lcd C:\ftp\backup
mget public_html*
quit

here is the contents of listfile.txt

C:\ftp\backup\*

 

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 3677371 posted 8:49 am on Jun 18, 2008 (gmt 0)

try using glob in ftp.txt to change the file name expansion.
this may preserve the directories for you.

bill

WebmasterWorld Administrator bill us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3677371 posted 9:12 am on Jun 18, 2008 (gmt 0)

Good suggestion phranque.

I stopped using this method years ago because it is very unsafe to use FTP like this. If it was inside a secured network that might be a different story. You should be using SFTP or another form of secure connection. ftp.exe does not allow for this.

Many of the better FTP tools will allow you to schedule a secure transfer and maintain the folder structure at the same time. Some will also compress the files for you.

drooh

5+ Year Member



 
Msg#: 3677371 posted 4:15 pm on Jun 18, 2008 (gmt 0)

thanks for the info guys, Bill do you know of any specific examples or what keywords I could use in my searching? thanks!

drooh

5+ Year Member



 
Msg#: 3677371 posted 1:53 am on Jun 19, 2008 (gmt 0)

also how would i emplement the glob command in this, any examples?

bill

WebmasterWorld Administrator bill us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3677371 posted 2:48 am on Jun 19, 2008 (gmt 0)

do you know of any specific examples or what keywords I could use in my searching?

Many of the FTP clients [webmasterworld.com] in the referenced thread have these capabilities.

how would i emplement the glob command

The -g switch [technet.microsoft.com] works with ftp on the command line.

drooh

5+ Year Member



 
Msg#: 3677371 posted 3:46 am on Jun 19, 2008 (gmt 0)

gosh darn i cant seem to make sense of this? with the code I have above how to I do this? I just want to ftp the entire directory keeping the folder structure in tact. Can it be done? I think so but I dont know how! I need some one to show me very clearly...

drooh

5+ Year Member



 
Msg#: 3677371 posted 8:32 am on Jun 19, 2008 (gmt 0)

ohh and the point of all of this is to ultimately be automated through scheduled tasks.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft Windows OS (XP/NT/Vista/Windows 7/8/9/10)
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved