Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Xcopy OR ws_ftp script - merge FTP server's contents into single directory

Posted on 2003-10-21
6
Medium Priority
?
243 Views
Last Modified: 2007-12-19
Hi
I have an FTP site with files in lots of different folders.
I need to do on eof the following:

1.  Copy all files and folders from FTP server to local machine using FTP client, but all files must go in one directory on local machine:
Server:
   \foo\file1.txt
   \foo\file2.txt
   \bar\file3.txt
   \bar\file4.txt
should be saved on the local machine all in one folder such as D:\ (not split in \foo, \bar as they were on the server).
This should/could be done using a WS-FTP or Robo FTP (or any other client) Script.  


-- OR --

2.  I will copy the exact structure from the FTP sevrer to the local machine.  I then need a batch file (xcopy based?) that will merge the contents of all the sub dirs into one folder:
   \foo\file1.txt
   \foo\file2.txt
   \bar\file3.txt
   \bar\file4.txt
should all be copied into D:\.



In both cases, if possible, file name conflicts should be resolved.


Thanks
Daniel
0
Comment
Question by:jasww
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 16

Expert Comment

by:_nn_
ID: 9592377
1. with ncftp (http://www.ncftpd.com/ncftp/), get a local copy (I think ncftpget -R should work) in a temporary location
2. with xxcopy (http://www.xxcopy.com/), "flatten" the temporary folder to the final one (see http://www.xxcopy.com/xxcopy16.htm for details)
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9592386
Sidenote : xxcopy works over networks, but then, isn't free any longer. Hence my proposition to get the tree with ncftp.
0
 

Author Comment

by:jasww
ID: 9597507
Hi _nn_
Thanks for the posts.
However I can already use my (graphical) FTP client to download recursivly.  
I need a script for any FTP client that will download the contents of remote folders to one local folder.
Thanks
Daniel
0
Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

 
LVL 16

Accepted Solution

by:
_nn_ earned 1000 total points
ID: 9597592
Well then, I'd propose using wget :
http://gnuwin32.sourceforge.net/packages/wget.htm

With a command line like following :

wget -r -nd ftp://user:pass@host.domain.tld//base/path

I'm getting the requested behavior, i.e., all files in the ftp tree in one local directory, and filename confilcts are resolved (no overwriting)
0
 

Author Comment

by:jasww
ID: 9597657
Brilliant _nn_ that's just what I need.
Many thanks.

Points for this Q guaranteed, but for an extra 50 points, can you tell me how to get wget to download the files and then delete them from the server?
The --delete-after removes them from the client.

Many thanks
Daniel
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9598195
Hmmm, gave it a (long) thought, but didn't come with something useful yet. For sure, wget can't do that. cURL (http://curl.haxx.se/) can do a "retrieve and delete from server", unfortunately it's not built for dealing with directory trees. I'll keep trying to find something, but without guaranty...
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

EE introduced a new rating method known as Level, which displays in your avatar as LVL. The new Level is a numeric ranking that is based on your Points. This article discusses the rationale behind the new method and provides the mathematical formula…
Stuck in voice control mode on your Amazon Firestick?  Here is how to turn it off!!!
Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.
Saved searches can save you time by quickly referencing commonly searched terms on any topic. Whether you are looking for questions you can answer or hoping to learn about a specific issue, a saved search can help you get the most out of your time o…
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question