Python ftp download all files in a directory
So far I have managed to connect and fetch one file, but I cannot seem to make to work in batch get all the files from the directory Here is what I have so far: from ftplib import FTP import os, sys, os. Mark Amery k 65 65 gold badges silver badges bronze badges.
Sosti Sosti 1 1 gold badge 4 4 silver badges 4 4 bronze badges. Add a comment. Active Oldest Votes. Oran 7 7 silver badges 13 13 bronze badges. Sosti Sosti 4 4 silver badges 2 2 bronze badges. The recommended way is to use: ftp. Please see this link — Oran. How does ftp. This answer seems to be incomplete. However, if this is a learning exercise for you and you'd like to make your program work, I think you should start by looking at this line: for subdir, dirs, files in os.
Sosti, the retrlines function mention in my post is a hyperlink off to the documentation : — sarnold. Thanks a lot for that, they all sound like solid suggestions!
I forgot to mention i m using Python 2. Sosti, you would still need to modify your code: you can't use the os. I'll edit my answer in a bit to show how to make a callback object for retrlines. I have to admit I need to do some research on this, and attempt to write some lines of code. I was hoping the problem could be fixed by tweaking some lines but apparently the issue is more fundamental.
Will do my best and then come back with any results. Thanks for all the input and suggestions! A recursive solution py 2. FTP addr ftp. Iulian Bute Iulian Bute 31 1 1 bronze badge. Bye" except: print "try again you can do it" finally: print "code ran". Network Switch. Python - Installation on Windows. Python - Virtual environment on Windows. Python - Virtual environment on Linux. Python - CGI on Apache. Python - CGI on Nginx. Python - Download file from FTP server. Equipment list.
The following section presents the list of equipment used to create this tutorial. Windows File Explorer. Mac OS X. Other FTP Clients. Command Line FTP. Previous Post. Can Bichon Frise eat peppers? Next Post. What film is best for Canon AE 1 program?
0コメント