Checking if object on FTP server is file or directory using Python and ftplib

There’s no better way (with FTP protocol in general, not just with ftplib).

The MLST/MLSD is the only correct and reliable way.

If you cannot use MLST/MLSD, trying CWD is the next best option.

Trying to parse LIST is a fallback option. But you need to know that the server uses listing format your program understands.

Leave a Comment