This is the code that lists all the subdirectories from FTP server. How do I search for the most recent Excel files sitting in these multiple Subdirectories directory? As shown in the results, I want to go through all the ls****
subdirectories and notify me if there is an Excel file with today's date.
Thanks in advance!
from ftplib import FTP
def handleDownload(block):
file.write(block)
print ".",
ftp = FTP('connect to host,'name', 'dflt port')
directory = 'Dir_name'
ftp.cwd(directory)
data = []
ftp.dir(data.append)
ftpContentList = ftp.retrlines('LIST') # list directory contents
Results:
drwxrwx--- 4 17610000 smartfile 4096 Jul 21 19:31 ls0125
drwxrwx--- 4 17610000 smartfile 4096 Jul 19 20:34 ls0146
drwxrwx--- 4 17610000 smartfile 4096 Jul 21 19:31 ls0265
drwxrwx--- 4 17610000 smartfile 4096 Jul 19 20:34 ls0368