Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a batch file containing WinSCP commands to upload files in different folders. Now, file names and folder name contain blank spaces.

It's showing an error when I'm running the batch file with those files and folders. The upload is successful when there aren't any blank spaces.

Below is the batch command that I'm running:

cd \
cd C:\Program Files\WinSCP /command "option echo off" "option batch on" "option confirm off" "open sftp" "put C:\abc\EXCEL\RestaurantAutomation\RestaurantReport_2012120172514\x y Report_P10_0010050075.xls /abc/MG0047/System Generated/x y Report_P10_0010050075.xls" "exit"

The error that I'm getting is:

Cannot create remote file ' /Generated/x y Report_P10_0010050075.xls'.
The file path does not exist or is invalid.
Error Code:10
Request code:3
share|improve this question

Wrap the name-with-space with double quote again. /command "option echo off" "option batch on" "option confirm off" "open sftp" "put ""C:\abc\EXCEL\RestaurantAutomation\RestaurantReport_2012120172514\x y Report_P10_0010050075.xls"" ""/abc/MG0047/System Generated/x y Report_P10_0010050075.xls""" "exit"

Update: Updated the command.

share|improve this answer
Tried using the above suggestion. Error coming is :Unknown command 'Generated\x y Report_P10_0010050075.xls' – Somalia Jan 25 '12 at 12:32
My bad. Had to add two extra quotes. Can you try now? – Bibhas Jan 25 '12 at 12:39
Tried using double quotes.File or folder 'C:\abc\EXCEL\RestaurantAutomation\RestaurantReport_20121201 72514\x y Report_P10_0010050075' does not exist. – Somalia Jan 30 '12 at 7:34
The syntax with double double-quotes is explained here: – Martin Prikryl Jun 13 '14 at 7:10

Try it like this. /command "option echo off" "option batch on" "option confirm off" "open sftp" "put C:\abc\EXCEL\RestaurantAutomation\RestaurantReport_2012120172514\""x y Report_P10_0010050075.xls"" /abc/MG0047/""System Generated""/""x y Report_P10_0010050075.xls""" "exit"
share|improve this answer
Could you explain what your command does? It's quite long... – Tom Wijsman Feb 7 '12 at 14:53

Have you tried escaping the spaces?

/abc/MG0047/System Generated/x\ y\ Report_P10_0010050075.xls

Other possibility would be to put the folders itself within quotes, but since there allready are some it might lead to confusioun.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .