14

I want to include the path to a library in the Program Files directory, but I need to do this without spaces. I know that Windows uses a convention that shortens names like Program Files becomes PROGRA~1. How can I find these shortened names for an arbitrary directory?

(Apologies if this has already been asked but I couldn't find it.)

  • Can't you just use quotation marks so you can leave the spaces in place? e.g., "C:\Program Files" – Uninspired Dec 2 '10 at 0:56
24

You can use for each folder:

DIR /X
  • 2
    also don't forget dir /x /a for hidden files – Drew LeSueur Aug 5 '11 at 9:06
  • 1
    doesnt work on win 10 – AndroidMechanic - Viral Patel Apr 5 '17 at 11:55
  • Doesn't this just show the short name for the file itself but not the folder ? – Chad May 2 '17 at 14:32
  • It will work on Windows 10. I used Powershell and was in my home directory, which has a space between my first and last name. I ran DIR/X .. and it spit out my shortened directory(s) I needed to see. – Rockin4Life33 Aug 27 at 4:24
1

in cmd, go to required directory and type dir/x to see the shortened name for your required folder

1

There is a better way to reference the Program Files folder : use the %PROGRAMFILES% variable. And there is no spaces in it :).
For instance : %PROGRAMFILES%\MyLib\MyLib.dll

protected by BinaryMisfit Dec 2 '10 at 7:24

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.