これは、FTP サーバーからすべてのサブディレクトリを一覧表示するコードです。これらの複数のサブディレクトリ ディレクトリにある最新の Excel ファイルを検索するにはどうすればよいですか? 結果に示されているように、すべてのls****
サブディレクトリを調べて、今日の日付の Excel ファイルがあるかどうかを通知したいと考えています。
前もって感謝します!
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
結果:
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