Directory transfers with Paramiko

How do you use Paramiko to transfer complete directories? I’m trying to use:

sftp.put("/Folder1","/Folder2")

which is giving me this error –

Error : [Errno 21] Is a directory

Answer

You’ll need to do this just like you would locally with python (if you weren’t using shutils).

Combine os.walk(), with sftp.mkdir() and sftp.put(). You may also want to check each file and directory with os.path.islink() depending on whether you want to resolve symlinks or not.