So lets say I\'m using Python\'s ftplib to retrieve a list of log files from an FTP server. How would I parse that list of files to get just the file names (the last column) ins
If the FTP server supports the MLSD
command, then please see section “single directory case” from that answer.
Use an instance (say ftpd
) of the FTPDirectory
class, call its .getdata
method with connected ftplib.FTP
instance in the correct folder, then you can:
directory_filenames= [ftpfile.name for ftpfile in ftpd.files]