0

How to download multiple files from different location folders from WinSCP server to the local folder using python script?

Is there any python module available which I can import and use that to download the files.

Note: I am using putty to log in to WinSCP.

1 Answers1

0

There's nothing like "WinSCP server". WinSCP is a client that can connect using various protocols to a remote file server. How you implement the same in Python depends on actual protocol you use with WinSCP. Based on your reference to "PuTTY", I assume you use SSH/SFTP.

For an SFTP download, use Paramiko Python library with its SFTPClient.get method. An example of a download of a single file:

with paramiko.SSHClient() as ssh:
    ssh.connect(host, username=username, password=password)
    with ssh.open_sftp() as sftp:
        sftp.get("/remote/path/file.txt", "/local/path/file.txt")

You will also have to deal with the server's host key verification.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992