Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6192837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:00:49+00:00 2026-05-24T03:00:49+00:00

the problem is: I have a local directory ‘/local’ and a remote FTP directory

  • 0

the problem is:

I have a local directory ‘/local’ and a remote FTP directory ‘/remote’ full of subdirectories and files. I want to check if there are any new files in the sub-directories of ‘/remote’. If there are any, then copy them over to ‘/local’.

the question is:

am I using the right strategy? Is this totally overkill and is there a much faster pythonic way to do it?
DISCLAIMER: I’m a python n00b trying to learn. So be gentle … =)
This is what I’ve tried:

Create a list of all files in /local and its sub-dirs.

LocalFiles=[]
for path, subdirs, files in os.walk(localdir): 
    for name in files:                     
        LocalFiles.append(name)

Do some ftplib magic, using ftpwalk() and copying its results to a list of the form:

 RemoteFiles=[['/remote/dir1/','/remote/dir1/','/remote/dir3/'],['file1.txt','file12.py','file3.zip']]

so I have the directory corresponding to each file.
Then see which files are missing by comparing the lists of filenames,

missing_files= list(set(RemoteFiles[1]) - set(LocalFiles))  

and once I’ve found their name, I try to find the directory that came with that name,

for i in range(0,len(missing_files)):
    theindex=RemoteFiles[1].index(missing_files[i])

which lets me build the list of missing files and their directories,

MissingDirNFiles.append([remotefiles[0][theindex],remotefiles[1][theindex]])

so I can copy them over with http://ftp.retrbinary.
Is this a reasonable strategy? Any tips, comments and advice is appreciated [especially for large numbers of files].

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:00:50+00:00Added an answer on May 24, 2026 at 3:00 am

    If you get the modification time of both the local and the remote FTP directories and store it in a data base, you could prune the search for new or modified files. This should speed up the sync procedure significantly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem when moving an uploaded file into a local directory. When
I have problem with return statment >.< I want to store all magazine names
I have a problem with a locally installed library. In my project there is
guys, I have the problem when copying database from local assets folder to /data/data/package_name/databases
Problem: I have an address field from an Access database which has been converted
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem I have timestamped data, which I need to search based on the timestamp
Problem: We have a web app that calls some web services asynchronously (from the
Problem: I have to support users who need to edit web pages. Some of
I have the following problem: I have an HTML textbox ( <input type=text> )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.