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.

ai tools vs traditional tools in bioinformatics
AI Tools vs Traditional Tools in Bioinformatics- Which one to select?
Algorithms Artificial Intelligence Machine Learning Software Tools
AI vs Physics in Molecular Docking
AI vs Physics in Molecular Docking: Towards Faster and More Accurate Pose Prediction
Artificial Intelligence Drug Discovery Machine Learning
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

You Might Also Like

Installing pycharm on Ubuntu
Bioinformatics ProgrammingPythonSoftwareTools

Installing Pycharm on Ubuntu (Linux)

May 26, 2021
wes_data_analysis Whole Exome Sequencing (WES) Data visualization Toolkit
Bioinformatics ProgrammingGitHubPython

wes_data_analysis: Whole Exome Sequencing (WES) Data visualization Toolkit

August 11, 2025
Bioinformatics ProgrammingPython

dssp_parser: A new Python package to extract helices from DSSP files.

May 10, 2022
Bioinformatics ProgrammingTools

Perl one-liners for bioinformaticians

December 8, 2015
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