Bioinformatics ReviewBioinformatics Review
Notification Show More
Font ResizerAa
  •  Home
  • Docking
  • MD Simulation
  • Tools
  • More Topics
    • Softwares
    • Sequence Analysis
    • Algorithms
    • Bioinformatics Programming
    • Bioinformatics Research Updates
    • Drug Discovery
    • Phylogenetics
    • Structural Bioinformatics
    • Editorials
    • Tips & Tricks
    • Bioinformatics News
    • Featured
    • Genomics
    • Bioinformatics Infographics
  • Community
    • BiR-Research Group
    • Community Q&A
    • Ask a question
    • Join Telegram Channel
    • Join Facebook Group
    • Join Reddit Group
    • Subscription Options
    • Become a Patron
    • Write for us
  • About Us
    • About BiR
    • BiR Scope
    • The Team
    • Guidelines for Research Collaboration
    • Feedback
    • Contact Us
    • Recent @ BiR
  • Subscription
  • Account
    • Visit Dashboard
    • Login
Font ResizerAa
Bioinformatics ReviewBioinformatics Review
Search
Have an existing account? Sign In
Follow US
Bioinformatics ProgrammingPython

How to download files from an FTP server using Python?

Dr. Muniba Faiza
Last updated: September 26, 2022 9:45 pm
Dr. Muniba Faiza
Share
1 Min Read
How to download files from an FTP server using Python?
SHARE

In this article, we provide a simple Python script to download files from an FTP server using Python.

Write the FTP address and your username and password in the place specified below. Save this file in Python format (for example, download.py) and run it as:

$ python3 download.py



#!/usr/bin/env python3

import fnmatch
from ftplib import FTP

ftp = FTP('ftp address')

#if no username and password is required.
ftp.login()

#if username and password is required.         
ftp.login('your-username','your-password')    

# if you have to change directory on FTP server.
ftp.cwd('/path/to/dir/')

# Get all files
files = ftp.nlst()

# Download files
for file in files:
    if fnmatch.fnmatch(file, '*.tar.gz'):   #To download specific files.
        print("Downloading..." + file)

        try:
            ftp.retrbinary("RETR " + file ,open("/path/to/dir/on/your/local/system/" + file, 'wb').write)

        except EOFError:    # To avoid EOF errors.
            pass

ftp.close()


TAGGED:download filesftp serverpubchempython scriptzinc
Share This Article
Facebook Copy Link Print
ByDr. Muniba Faiza
Follow:
Dr. Muniba is a Bioinformatician based in New Delhi, India. She has completed her PhD in Bioinformatics from South China University of Technology, Guangzhou, China. She has cutting edge knowledge of bioinformatics tools, algorithms, and drug designing. When she is not reading she is found enjoying with the family. Know more about Muniba
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

- Advertisement -
Ad image
10 years of Bioinformatics Review: From a Blog to a Bioinformatics Knowledge Hub!
Editorial
Starting in Bioinformatics? Do This First!
Starting in Bioinformatics? Do This First!
Tips & Tricks
[Editorial] Is it ethical to change the order of authors’ names in a manuscript?
Editorial Opinion
Installing bbtools on Ubuntu
[Tutorial] Installing BBTools on Ubuntu (Linux).
Sequence Analysis Software Tools

You Might Also Like

How to commit changes to GitHub repository using vs code?
Bioinformatics ProgrammingGitHub

How to commit changes to GitHub repository using vs code?

February 28, 2024
basic sql queries
Bioinformatics Programming

Basic SQL Queries to Create and Retrieve Information from a Database

September 19, 2020
Bioinformatics Programming

How to extract fasta sequences from a multi-fasta file based on matching headers in a separate file?

May 20, 2020
Bioinformatics ProgrammingPerl

How to concatenate FASTA sequences using Perl?

May 20, 2020
Copyright 2024 IQL Technologies
  • Journal
  • Customer Support
  • Contact Us
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Cookie Policy
  • Sitemap
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?

Not a member? Sign Up