0

go.bat

@echo off

set url=D:\Download\Path with space inside

echo "%url%"

pause

output:

C:\Users\Admin\Desktop>go
"D:\Download\Path with space inside"
Premere un tasto per continuare . . .

if i pass the parameter like this:

C:\Users\Admin\Desktop>go D:\Download\Path with spaces inside

@echo off

set url=%~1

echo "%url%"

pause

the output is wrong: the path is incorrect

C:\Users\Admin\Desktop>go D:\Download\Path with space inside
"D:\Download\Path"

any help please :D

0

1 Answer 1

0

With this batch file

@echo off

set url=%~1

echo "%url%"

pause

You need to pass the path in ""

C:\Users\Admin\Desktop>go "D:\Download\Path with space inside"

the command with its output will be :-

C:\Users\Admin\Desktop>go "D:\Download\Path with space inside"
"D:\Download\Path with space inside"

Please let me know if this works.

3
  • Do you see how my edit makes your post clearer? You wrote things like 'you need to pass the path in "" ' then you showed the command with batch file, putting the batch file there is not clear. And after you wrote the command, you wrote "the output will be", then you wrote the command with its output. I made your explanatory text say "the command with its output will be". That is clearer. And you should delete your other answer. In fact you could have edited your previous answer instead of posting a new one.
    – barlop
    May 1, 2014 at 16:45
  • Barlop Thanks for editing my post. I have deleted the other answer:) . May 1, 2014 at 19:42
  • your last solution is not working if the parameter is passed with a sendto --> go.bat with the context menu in a file or folder. i fixed it myself with set url=%~dpnx0 instead of url=%~1
    – Frontender
    May 1, 2014 at 20:49

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