Directory path having multiple space.

Advertisement

sumeetshinde
Joined:
Posts:
2

Directory path having multiple space.

Hi,

I am writing a below script. Need help to fix quote issue for define path.
If i use below CODE1 everything work fine. But when i use CODE2 unable to get into sub directory path & get error. I try to adjust quote but still same issue.
As you can see ERROR it show single quote before "department" word. If i remove that from CODE2 set it as (set pathname1="Q:\"""Fall 2020\"""Department Stores"") it show error as ( File or folder 'Q:\Fall 2020\Department' does not exist.).
Let me know how can we fix this.

Code1:
@echo off
set pathname0="Q:\"""Fall 2020\""
 "C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://***/ -hostkey=""ssh-*****="" -rawsettings FSProtocol=2" ^
   "cd /BIDATA/Testfolder" ^
   "put -filemask="*.xlsx" %pathname0%" ^ 
    "exit" ^
Code2:
@echo off
set pathname1="Q:\"""Fall 2020\""""Department Stores""
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://*********/ -hostkey=""ssh-****"" -rawsettings FSProtocol=2" ^
   "cd /BIDATA/Testfolder/" ^
   "put %pathname1%" ^ 
    "exit"^
Error:
Active session: [1] BITEAM@******
/BIDATA/Testfolder
File or folder 'Q:\Fall 2020\"Department Stores' does not exist.
System Error.  Code: 2.
The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all: Abort

Thanks

Reply with quote

Advertisement

sumeetshinde
Joined:
Posts:
2

Re : Directory path having multiple space.

Thanks Martin, for helping but that doesn't work. Getting below error while passing the value, seems like it's considering "Department stores" as a different folder while copying.

***error****
Are you sure you want to transfer multiple files to a single file 'Stores"' in a directory '/BIDATA/Testfolder'?
The files will overwrite one another.
If you actually want to transfer all files to a directory '/BIDATA/Testfolder/Stores"/', keeping their name, make sure you terminate the path with a slash.
File or folder 'Q:\Fall' does not exist.
System Error. Code: 2.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,453
Location:
Prague, Czechia

Re: Re : Directory path having multiple space.

Please first start with a hard-coded path (without the %pathnameX% variables).
   "put ""Q:\Fall 2020\Department Stores\""" ^
If it does not work, post again your full script (with hard-coded path) and the log file.

Reply with quote

Advertisement

You can post new topics in this forum