Winscp- want ot upload multiple files

Advertisement

gnanasundram
Joined:
Posts:
3
Location:
Hyderabad

Winscp- want ot upload multiple files

Hi,

I am using winscp.exe to upload the file to server, but i am face some problem while uploading the files.
If i send a file by using the command PUT abc.txt then the file is uploaded successfully.
But i want to upload multiple file so i used below command.

PUT *.csv or PUT *.* command it says the file not found.

Can you please suggest on this and give a solution the error.

Thanks in advance

Regards,
Gnansundram

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
38,659
Location:
Prague, Czechia

Re: Winscp- want ot upload multiple files

What is the actual problem?
1) There are files macthing the mask and WinSCP does not find them
2) There are indeed no files macthing the mask and you want WinSCP to silently do nothing
Also what version of WinSCP are you using?

Reply with quote

gnanasundram
Joined:
Posts:
3
Location:
Hyderabad

Hi,

Thanks for your reponse.
I want to upload a file to server using SFTP and for that i use winscp.exe.(using GUI working fine) winscp version 3.7.1
now i want to automate the file transfer.
I tried the below script for automation:
Batch file
start "D:\new test\" winscp.exe /console /script=sample.txt"

Sample.txt

open username:password@ipaddress:10022
option batch on
option confirm off
cd /filename
put "Z:\*.csv"
now when iclick on bat file it connect to server and get stoped in the put command and shows an error file not found,but when i give file put filename.csv then the file get uploded.

Reply with quote

TimU
Joined:
Posts:
25
Location:
Sydney

Your SAMPLE.TXT script seems flawed.

Try this:
Sample.txt
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Force binary mode transfer
option transfer binary
# Establish the connection
open username:password@ipaddress:10022
# Change the Local Directory
lcd "Z:\"
# Change to the correct Remote directory
cd /<RemoteDirectory>
# List the local files
lls
# List Remote Files
ls
# Upload *.csv
put "*.csv"

This will give you a list of the Local Directory and the Remote Directory so you can be sure you're looking at the correct locations.

I'm assuming that Z: refers to a mapped network drive? Pls be aware that this won't be available if you're planning on running this script as a scheduled task, unless you map it manually in the tasks batch file.

You're better off using this command to be universally accessible:
# Change the Local Directory
lcd "\\servername\share"


Hope this helps.
Tim

Reply with quote

Advertisement

Guest

Hi,
Thanks for sample script,but i am getting the same error.
i followed the same step which you have given.but i am getiing the below error
winscp>put *.CSV
*.csv 0kb 0.0kb/s binary 0%
file or folder '*.csv' does not exit
but when i give filename.csv transfer successfull shows below message.
winscp>put filename.csv
filename 0kb 0.1kb/s binary : 100%


but i want to transfer multiple file at a time.

Thanks and Regards,
Gnanasundram

Reply with quote

TimU
Joined:
Posts:
25
Location:
Sydney

Can you paste the output of both of these commands please?

# List the local files
lls
# List Remote Files
ls

Tim

Reply with quote

martin
Site Admin
martin avatar

Re: Winscp- want ot upload multiple files

3.7.1 does not support file masks in scripting commands. Please upgrade to the latest version.

Reply with quote

Guest

Re: Winscp- want ot upload multiple files

martin wrote:

3.7.1 does not support file masks in scripting commands. Please upgrade to the latest version.
Hi,
Thanks for your response,
I have installed winscp(version 4.3.3) in my machince but i dont know how to run winscp in command mode
Can you please suggest me how to write a bat file which runs winscp in command mode.

Thanks and Regards,
Gnanasundram

Reply with quote

Advertisement

gnanasundram
Joined:
Posts:
3
Location:
Hyderabad

Re: Winscp- want ot upload multiple files

[quote="Anonymous"]

martin wrote:

3.7.1 does not support file masks in scripting commands. Please upgrade to the latest version.
Hi,
Thanks for your response,
I have installed winscp(version 4.3.3) in my machine.
the script is working fine
but while sending file it show an error atating that "Ignore permission errors" while sending the file.
please guide me how to correct the error.

Thanks and regards,
Gnana sundram.

Reply with quote

TimU
Joined:
Posts:
25
Location:
Sydney

Re: Winscp- want ot upload multiple files

gnanasundram wrote:


I have installed winscp(version 4.3.3) in my machine.
the script is working fine
Why did you install v4.3.3 and not the latest version 4.3.7?

gnanasundram wrote:


but while sending file it show an error atating that "Ignore permission errors" while sending the file.
please guide me how to correct the error.

Does your account have access to upload files to the server?

Reply with quote

Advertisement

clt
Guest

order of uploading files

Hi Martin, or anybody..
Is it possible to control the order of files uloading on the server? I have .gpg and .chk files and winscp uload .chk firstly (I assume that in alphabetical order). I need to upload e.g. first.gpg, then first.chk, second.gpg then second.chk etc. Thank you!

Reply with quote

TimU
Joined:
Posts:
25
Location:
Sydney

Re: order of uploading files

clt wrote:

Hi Martin, or anybody..
Is it possible to control the order of files uloading on the server? I have .gpg and .chk files and winscp uload .chk firstly (I assume that in alphabetical order). I need to upload e.g. first.gpg, then first.chk, second.gpg then second.chk etc. Thank you!

You could either:
1) Script it externally then call WinSCP with a known list of files to transfer.
2) Run multiple WinSCP passes over your source directory, first transferring *.gpg, then *.chk.

Here's an extract of a Windows Batch script that will append file names to an existing SFTP Batch Script
--------------------------------
DIR /a-d /b *.gpd %source.path% >%SFTP.batch.filelist%
DIR /a-d /b *.chk %source.path% >>%SFTP.batch.filelist%

:: If there are no files in the source directory to transfer, leave the script.
if errorlevel==1 (@ECHO Nothing To Do - Exiting Script)&(Goto :EOF)

@ECHO File Listing Complete

:: Now echo the file names to the script, including the SFTP.OPERATION we want to perform.
@ECHO Echo the file names to the SFTP Script file
for /f "tokens=*" %%A in (%SFTP.batch.filelist%) do (echo PUT -preservetime "%%A" >>%SFTP.batch.script%)

--------------------------------

Reply with quote

moonchild18
Guest

I can't send multiple Files to a sftp server

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
open sftp:// .....
# Change the Local Directory
lcd "E:\Export Data\"
# Change remote directory
cd /Home/
# Force binary mode transfer
option transfer binary
# List the local files
lls
# List Remote Files
ls
# Upload the files to current working directory
put *.csv
# Disconnect
close
# Exit WinSCP
exit

The following script is loading only one file to the sftp server instead of loading all the files.

I'm using winscp517 version.

Can you please tell me what I'm doing wrong?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
38,659
Location:
Prague, Czechia

Re: I can't send multiple Files to a sftp server

moonchild18 wrote:

The following script is loading only one file to the sftp server instead of loading all the files.

I'm using winscp517 version.

Can you please tell me what I'm doing wrong?
Please start a new thread and attach a full log file showing the problem (using the latest version of WinSCP).

To generate log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.

Reply with quote

Advertisement

vsrselenium@...
Guest

I want to upload more than one file from my local directory to SFTP directory

I want to upload more than one file from my local directory to SFTP directory I tried with the below code at that time only one file got uploade
"sFTPScript = sFTPScript & "Put " & LocalFolderPath &"*.*" & vbCRLF".

please hemp me how I achieved this.

Thank you in advance.


Kind Regards,
Sreehari Valluri

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
38,659
Location:
Prague, Czechia

Re: I want to upload more than one file from my local directory to SFTP directory

vsrselenium@... wrote:

I want to upload more than one file from my local directory to SFTP directory I tried with the below code at that time only one file got uploade
"sFTPScript = sFTPScript & "Put " & LocalFolderPath &"*.*" & vbCRLF".

please hemp me how I achieved this.
Please, start a new thread. Post a complete code (your code snippet is useless) and a complete session log file.

Reply with quote

Advertisement

You can post new topics in this forum