0

PowerShell has issues with spaces in directory names.

I am trying to execute a file in the same directory as the PS1 script like so:

.\getGravatarsForGource.pl

It works fine when the directory names do not have spaces in them (I changed the folder from Git to Git stuff on purpose) and I don't know how to make it execute correctly.

I could just change the folder name back to Git, what it was before, but it is an issue I want to solve because other people downloading my repository may not want to rework their entire filesystem so that they have no spaces in their directories.

FYI: Yes, I also tried it like ".\getGravatarsForGource.pl"

Output of PowerShell

The term 'D:\Joshua\!Coding\Git' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:22
+ D:\Joshua\!Coding\Git <<<< stuff\centaur-XML-Tool\gource\executables\run-gource-for-windows.ps1
    + CategoryInfo          : ObjectNotFound: (D:\Joshua\!Coding\Git:String) [], CommandNotFoundEx
   ception
    + FullyQualifiedErrorId : CommandNotFoundException
  • The path isn't hard coded anywhere, is it? – Davidw Nov 2 '14 at 21:39
  • Errors do not expand variables. So that error indicates that the path is in the code as a string literal. Put quotes around it in the code. – EBGreen Nov 3 '14 at 14:37
  • You may need single-quotes instead of double-quotes. Try this: 'D:\Joshua\!Coding\Git stuff\centaur-XML-Tool\gource\executables\run-gource-for-windows.ps1' or this Set-Location 'D:\Joshua\!Coding\Git stuff\centaur-XML-Tool\gource\executables\';.\run-gource-for-windows.ps1 – Iszi Feb 10 '15 at 6:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.