Python ftplib - loading multiple files?

I have googled, but I can only find how to upload one file ... and I'm trying to upload all the files from the local directory to the remote ftp directory. Any ideas how to achieve this?

+3
source share
3 answers

with a cycle?

edit : in the universal case, downloading only files will look like this:

import os
for root, dirs, files in os.walk('path/to/local/dir'):
    for fname in files:
        full_fname = os.path.join(root, fname)
        ftp.storbinary('STOR remote/dir' + fname, open(full_fname, 'rb'))

Obviously, you need to look for name conflicts if you just save file names like this.

+10
source

Take a look at the Python scripts needed to create boot files from JSON-Call and then FTPlib-operation: why are some loaded and others not?

, , , URL- ftplib json-file xml : 024 .

URL- , .

, json xml, , "" 2 , FTP_Upload.

0

FTP ( , ). python ftp.exe "-s" .

kludgy, , , FTPlib STOR.

ftp.

*

OPEN inetxxx 
myuser mypasswd 
binary 
prompt off 
cd ~/my_reg/cronjobs/k_load/incoming 
mput *.csv 
bye
  • "abc.ftp" - ftp

    ftp -s abc.ftp

, .

-1
source

Source: https://habr.com/ru/post/1712306/


All Articles