It comes about now and again that you need to get an old style Dos 8.3 file or path name to satisfy some legacy application or to represent a standard path without the blank spaces in it. Here's an example of a Dos 8.3 path to Spotify in my Dropbox:
C:\Mydrop~1\Apps\spotify\spotify.exe
The path you'd normally see would be:
C:\My Dropbox\Apps\spotify\spotify.exe
If I tried to launch the normal link from the command line it'd fail because it wouldn't be able to resolve the path correctly.
But using the shortened Dos version causes no problems because it doesn't contain any spaces. So rather than trying to wrap the standard path in quotes for a program that isn't expecting spaces you can pass the Dos 8.3 path instead.
Here's an AutoHotkey script that will take the current highlighted text, copy it to the clipboard, convert it to the Dos 8.3 path and paste back to the clipboard.
capslock & d::
Send ^c
ClipWait,1
If Errorlevel
{
MsgBox, Error copying to the clipboard!
return
}
newPath := GetShortPath(Clipboard)
if newPath =
{
MsgBox, To Dos Path - Invalid source path!
}
Clipboard := newPath
ClipWait, 1
If Errorlevel
{
MsgBox, Error pasting to the clipboard!
return
}
return
GetShortPath(LongPath) {
Loop, %LongPath%, 1
Return A_LoopFileShortpath
}
The script is fired by pressing capslock & d. If the path is incorrect, there are problems accessing the clipboard or no text is highlighted the script will inform you with a message box. If everything goes as planned then the new shortened path will be silently copied to the clipboard. Take a look at the AutoHotkey documentation if you’d like to change this to a different keyboard shortcut.