Topic "Want to upload multiple files using SFTP to remote server"

Author Message
skumarlingamNC

Guest


Hello Experts,

I am trying to upload multiple files using below script, somehow batch script picking only first file out of multiple files from local drive and uploads on remote server.

WinScp version 5.9.2

batch command

Code:
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log= V:\BatchScripts\File_Put.log /script=V:\BatchScripts\File_Put.txt


File_Put.txt

Code:
# Connect to SFTP server using a password
open sftp://username:password;fingerprint=ssh-**s-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**@sftp.**.com/XYZ/WVW_to_User/
# Upload file
put V:\*.csv /XYZ/WVW_to_User/
exit


Please let me know is there any wrong with script.

Thank you in advance.
[/code]
Advertisements
Guest




I think you can try doing an LCD to change the directory then try the transfer.

# Connect to SFTP server using a password
open sftp://username:password;fingerprint=ssh-**s-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**@sftp.**.com/XYZ/WVW_to_User/
# Upload file
lcd V:\
put *.csv /XYZ/WVW_to_User/
EXIT
skumarlingamNC

Guest


Thank you my friend.

I will try and let you know the progress.

Thank you in advance.


Anonymous wrote:
I think you can try doing an LCD to change the directory then try the transfer.

# Connect to SFTP server using a password
open sftp://username:password;fingerprint=ssh-**s-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**@sftp.**.com/XYZ/WVW_to_User/
# Upload file
lcd V:\
put *.csv /XYZ/WVW_to_User/
EXIT
skumarlingamNC

Guest


sorry I changed code as per your suggestion. batch script picking first file and uploading on remote server. not picking other files.

Thank you in advance.
Guest




It must be erroring out. I would enable logging to see what exactly is happening. You can also try disabling the permission and timestamp setting to see if that's the problem. https://winscp.net/eng/docs/message_preserve_time_perm


# Connect to SFTP server using a password
open sftp://username:password;fingerprint=ssh-**s-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**@sftp.**.com/XYZ/WVW_to_User/
# Upload file
lcd V:\
put *.csv /XYZ/WVW_to_User/ -nopreservetime -nopermissions
EXIT[/quote][/quote]
skumarlingamNC

Guest


You are my hero Thank you. Finally I can upload all my multiple files.

here is the code the one suggested by you.

Code:
# Connect to SFTP server using a password
open sftp://username:password;fingerprint=ssh-**s-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**@sftp.**.com/XYZ/WVW_to_User/
# Upload file
lcd V:\
put *.csv /XYZ/WVW_to_User/ -nopreservetime -nopermissions
EXIT


Thank you once again.
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 16
Location: SoVA
Awesome. Happy to help Cool
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
There's hardly any difference between put V:\*.csv and lcd V:\ + put *.csv.

It actually looks like the problem was this one, right?
https://winscp.net/eng/docs/message_preserve_time_perm

If that's the case, this is the only needed change:

put V:\*.csv /XYZ/WVW_to_User/ -nopreservetime

(the -nopermissions is the default)
skumarlingamNC

Guest


sorry for late reply.

Correct. below line is enough to upload multiple files via sftp.

Code:
-nopreservetime


thank you though for helping me.

Is that possible after uploading files on remote server can we suffix today's(current) datetime to each file
Code:
(example file name: XYZ_10_14_2016.csv)


Please let me know if you want me to open in spread thread.

Thank you in advance.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
This should work:

put V:\*.csv /XYZ/WVW_to_User/*_%TIMESTAMP#DD_MM_YYYY% -nopreservetime

See https://winscp.net/eng/docs/scripting#timestamp
skumarlingamNC

Guest


Worked like a charm; Thank you.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License