473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to get all the file of a oppoint directory from a FTP

There are no such a method using to download a whole directory in the
lib of ' ftplib '.
thanks for anybody's help!

Sep 6 '06 #1
4 1076

snowf wrote:
There are no such a method using to download a whole directory in the
lib of ' ftplib '.
thanks for anybody's help!
So you'll have to lash one up:

(untested)

Firstly,
alist = []
ftpobj.retrlines('list', alist.append)
should get you a list of filenames.

Secondly,

for fname in alist:
f = open(fname, "wb")
ftpobj.retrbinary('RETR ' + fname, f.write)
f.close()

should do the business. Instead of using f.write as the callback, you
might like to wrap that in a function that counts the bytes received,
displays progress, etc.

HTH,
John

Sep 6 '06 #2

John Machin wrote:
snowf wrote:
There are no such a method using to download a whole directory in the
lib of ' ftplib '.
thanks for anybody's help!

So you'll have to lash one up:

(untested)

Firstly,
alist = []
ftpobj.retrlines('list', alist.append)
should get you a list of filenames.

Secondly,

for fname in alist:
f = open(fname, "wb")
ftpobj.retrbinary('RETR ' + fname, f.write)
f.close()

should do the business. Instead of using f.write as the callback, you
might like to wrap that in a function that counts the bytes received,
displays progress, etc.

HTH,
John
Thanks for you reply!
I will have a try with your suggest and show the result later.

Sep 6 '06 #3
snowf wrote:
There are no such a method using to download a whole directory in the
lib of ' ftplib '.
thanks for anybody's help!
If your Python distrbution contains a "Tools" directory you should look
for the "ftpmirror.py" utility in it. If you don't have Tools then you
can extract them from the Python source tarball.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Sep 6 '06 #4

Steve Holden wrote:
snowf wrote:
There are no such a method using to download a whole directory in the
lib of ' ftplib '.
thanks for anybody's help!
If your Python distrbution contains a "Tools" directory you should look
for the "ftpmirror.py" utility in it. If you don't have Tools then you
can extract them from the Python source tarball.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Thank you for your reply .

: )

Sep 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
5
by: matt dittman | last post by:
I have created a windows service that reads emails from a drop directory and moves them to the appropriate mail folder every 15 seconds. I can move, rename and delete the files as needed, up...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: tasahmed | last post by:
Hello Friends, I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.