Recursive SFTP listdir in Python?

后端 未结 1 769
天涯浪人
天涯浪人 2020-12-18 15:47

I need to recursively list the content of a directory that contains a lot of subdirectories (more than 16,000).

I am currently using Paramiko\'s SFTP client, which d

相关标签:
1条回答
  • 2020-12-18 16:22

    So I have to first run listdir on the parent folder, and then another listdir for each of the (many, many) subdirectories.

    That's the correct approach.

    For an example of an implementation, see
    Python pysftp get_r from Linux works fine on Linux but not on Windows


    Is there any way to run the recursive listdir in a single SFTP call? I'm not limited to the Paramiko package, it's just the package that we're currently using.

    No. That's not limitation of Paramiko. SFTP protocol itself does not have any way to retrieve recursive listing. Not that other similar protocols (like FTP) have such functionality commonly, so it's not really a limitation.

    0 讨论(0)
提交回复
热议问题