Question

I'm using this code to upload all htm files to a web server but every time I run it I upload all files and I would like to upload only the new files.

try:
ftp.cwd('public_html')
F=open('Simple.png','rb')
tp.storbinary('STOR Simple.png',F,1024)
file.close(F)
for root, dirs, files in os.walk('C:\Relatorio'):
    for fname in files :
    if (fname.endswith(".HTM")) or (fname.endswith(".htm")):
        ftp.storbinary('STOR ' + fname, open(fname, 'rb'))
            print "FTP Enviado"
            except ftplib.all_errors,e:
            print 'Erro ao conectar ao servidor FTP\nErro:',e
Was it helpful?

Solution

You could possibly use the "last modified" time of the local and remote files as a crude way of estimating whether or not a file has changed since it was last uploaded.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top