I put together some code that loops through all folders in an FTP portal, and lists all the files, and zipped files,in the folder. This works great!
import csv
import ftplib
ftp = ftplib.FTP('portal', 'user_name', 'pswd')
contents1 = ftp.retrlines('LIST')
print(contents1)
ftp.nlst()
contents2 = ftp.nlst('emm')
print(contents2)
outF = open('C:\\path_to_file\\test.txt', 'w')
for line in contents1:
# write line to output file
outF.write(line)
outF.write("\n")
for line in contents2:
# write line to output file
outF.write(line)
outF.write("\n")
outF.close()
I don't want to download all files, because there are so, so, so many, and as such, this kind of task will take a very long time. I just want a snapshot, or inventory, of the contents of all folders, and sub folders, with details of all files (at least size of each file, maybe date of each file, and maybe a few other basic analytics too). How can I do that? TIA.