Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to use shortened path names for an application that I am using. For example I need C:\PROGRA~1\ as opposed to C:\Program Files. The program can't handle spaces and won't accept quoted paths e.g. "C:\Program Files".

If it helps, I am using Windows 7. I can get access to any version since XP if necessary.

share|improve this question
up vote 39 down vote accepted

Start, and type cmd in the run box. Start cmd, and use cd to get to the folder you are interested in:

cd \


dir /x

C:\>dir /x

13/10/2011  09:14 AM    <DIR>          DOCUME~1     Documents and Settings
13/10/2011  09:05 AM    <DIR>          PROGRA~1     Program Files
share|improve this answer
So you do this for every subfolder in the path? – endolith May 6 '15 at 18:19
@endolith The /s switch does subfolder recursion – Paul May 6 '15 at 21:43

create a bat file in your current directory and put inside it then you could copy+paste the short path from that path.

You could just run and keep doing cd commands to your current directory too.

In windows batch scripts, %~s1 expands path parameters to short names. Create this batch file:

echo %~s1

I called mine shortNamePath.cmd and call it like this:

c:\>shortNamePath "c:\Program Files (x86)\Android\android-sdk"

Edit: here's a version that uses the current directory if no parameter was supplied:

if '%1'=='' (%0 .) else echo %~s1

Called without parameters:

C:\Program Files (x86)\Android\android-sdk>shortNamePath

The SET variable example I can't figure out but this is pretty close might need some little fixes to make it work

SET TESTPATH="c:\Program Files (x86)\Android\android-sdk"
CALL :testargs "%TESTPATH%"
echo %~s1
share|improve this answer
Really useful, should be marked as answer! – lucaferrario Feb 19 '15 at 11:03
Thanks! Is it do-able using a SET command ? like SET AAA=C:\program files\what ever\another space in the middle\ to the short version – Li3ro May 20 '15 at 13:41
@Li3ro I couldn't figure out SET variable command way but I got pretty close, you can see it at the bottom of the answer just needs a little fix up. I'm not into batch script programming so I don't know how. – SSpoke May 26 '15 at 20:29
It is not doable this way. you need the for loop for this – Li3ro May 27 '15 at 4:18

The "short name" is really the old DOS 8.3 naming convention, so all the directories will be the first 6 letters followed by ~1 assuming there is only one name that matches, for example:

C:\BCDEFG~1 - C:\BCDEFGHIJKL M Another Directory

here is the only exception

C:\ABCDEF~2 - C:\ABCDEFGHI Directory as well

share|improve this answer
Not true. Sometimes fewer characters are used, particularly if you are using asian characters, such as Korean. – Arafangion Sep 5 '13 at 2:04
I suppose finding out which one is which in the "exceptional" case is the point of the question - especially as the "exception" regularly occurs in every Windows 64 bit installation, where you may need to know which one out of Program Files and Program Files (x86) is PROGRA~1 and which one is PROGRA~2. Paul's answer solves that issue. – O. R. Mapper Feb 1 '14 at 12:00
I have so many files that start with the same characters that after four of them (...~4) it started with what looks like hashing, e.g. ABxxxx~1 where x was hexadecimal -- which isn't very easy to read. – Sirap Nov 21 '14 at 23:07

Just replace the spaces with


It's the way things are "translated", and spaces go into %20.

If you really need alot, simply pop open your browser and type something like

test ";($#< and find the word test, and see that the space is %20 and so on...
share|improve this answer

You must log in to answer this question.

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