Skip to content

Instantly share code, notes, and snippets.

@timheuer
Created November 30, 2012 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timheuer/4177553 to your computer and use it in GitHub Desktop.
Save timheuer/4177553 to your computer and use it in GitHub Desktop.
batch with spaces
SET arch=%processor_architecture%
SET pf="C:\Program Files"
if "%arch%" == "AMD64" (
SET pf="C:\Program Files (x86)"
)
REM below fails because "pf" has spaces in it
REM using "%pf%\bar\baz\file.foo" also fails because then it looks at %pf% as a literal
copy \\some\path\file.foo %pf%\bar\baz\file.foo
@jredville
Copy link

copy \\some\path\file.foo '%pf%\bar\baz\file.foo' doesn't work?

@jessenic
Copy link

See my fork.

@smarx
Copy link

smarx commented Nov 30, 2012

Your SET commands are wrong. Try set pf=C:\Program Files (x86). (Don't put quotation marks.)

@smarx
Copy link

smarx commented Nov 30, 2012

Oh, I had missed jessenic's fork. That should also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment