Create a bat file in some convenient directory
then you could copy+paste the short path from that path.
You could just run command.com
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 OFF
echo %~s1
I called mine shortNamePath.cmd
and call it like this:
C:\> shortNamePath "c:\Program Files (x86)\Android\android-sdk"
c:\PROGRA~2\Android\ANDROI~1
Here's a version that uses the current directory if no parameter was supplied:
@ECHO OFF
if '%1'=='' (%0 .) else echo %~s1
Called without parameters:
C:\Program Files (x86)\Android\android-sdk> shortNamePath
C:\PROGRA~2\Android\ANDROI~1
Using SET
and a named variable
Windows Command Prompt has some conventions for handling variables
with spaces in their values that are somewhat hard to learn and understand,
especially if you have a Unix background.
You can do
SET TESTPATH=c:\Program Files (x86)\Android\android-sdk
(with no quotes), or
SET "TESTPATH=c:\Program Files (x86)\Android\android-sdk"
(note the non-intuitive placement of quotes); then
CALL :testargs "%TESTPATH%"
︙
:testargs
echo %~s1
goto :eof
So you do this for every subfolder in the path? – endolith – 2015-05-06T18:19:11.820
@endolith The
/s
switch does subfolder recursion – Paul – 2015-05-06T21:43:37.0871I mean how do you display the entire 8.3 path? – endolith – 2017-01-23T16:04:25.567
@endolith See the answer below – Paul – 2017-01-25T11:00:58.483
4@Paul This doesn't seem to work in Win10. Any ideas? – AHungerArtist – 2017-04-17T03:23:27.330
3@AHungerArtist The short file names don't necessarily exist; their creation can be turned off. – Hipponax43 – 2017-05-22T09:51:15.660
1
@AHungerArtist An alternative that I've used on occasion is to "roll your own": create a directory junction. This can be done with either the builtin
– dgnuff – 2018-11-03T21:19:02.710MKLINK.EXE
tool. or my option of choice, the Junction utility from Sysinternals: https://docs.microsoft.com/en-us/sysinternals/downloads/junction . Open a command prompt in the directory containing the subdirectory with spaces in its name, and enterJunction shortname "Long Name With Spaces"
.