Search code examples
windowsfile-uploadsftpputtypsftp

Unable to upload all files using wildcards with psftp


I wish to upload all files in C:\Users\myuser\Downloads\SFTP folder on my local Windows to remote SFTP server myfolder directory.

I have multiple issues running sftp on Windows and achieving the above.

Below is my command:

C:\putty\psftp.exe -b C:\putty\sftp_commands.txt -l myuser -pw mypass 10.8.44.86

Here is my C:\putty\sftp_commands.txt file:

mkdir myfolder
cd myfolder
lcd "C:\Users\myuser\Downloads\SFTP"
put "C:\Users\myuser\Downloads\SFTP\*.*"

I get "unable to open" error despite the file exists on my local Windows.

This works when I change C:\Users\myuser\Downloads\SFTP\*.* to C:\Users\myuser\Downloads\SFTP\file1.txt.

C:\Users\myuser\Desktop>C:\putty\psftp.exe -b C:\putty\sftp_commands.txt -l myuser -pw mypass 10.8.44.86
Using username "myuser".
Pre-authentication banner message from server:
| EFT Server Enterprise 7.3.2.8
End of banner message from server
Keyboard-interactive authentication prompts from server:
End of keyboard-interactive prompts from server
Remote working directory is /
mkdir /myfolder: OK
Remote directory is now /myfolder
New local directory is C:\Users\myuser\Downloads\SFTP
local: unable to open C:\Users\myuser\Downloads\SFTP\*.*

Can you please suggest what is wrong with my code?


Solution

  • put does not support wildcards, you have to use mput:

    lcd "C:\Users\myuser\Downloads\SFTP"
    mput *.*