jana
asked on
How to convert a path to short names in windows command prompt
Hi,
We are trying to take a regular path and convert it to "short name". For example:
The normal path:
Convert it to:
We understand fir /x returns the short name of a folder or file, but we are trying to convert specific path.
How can we go about this?
(we use Windows 10)
We are trying to take a regular path and convert it to "short name". For example:
The normal path:
C:\Program Files\AVAST Software\avast\
Convert it to:
C:\PROGRA~1\AVASTS~1\avast \
We understand fir /x returns the short name of a folder or file, but we are trying to convert specific path.
How can we go about this?
(we use Windows 10)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome! Btw, quotes are needed only when there are spaces in the folder or file name, such as the space in Program Files. They're not needed if there are no spaces in the folder/file name. For example, this works fine without the quotes:
shortname.bat c:\Windows\PolicyDefinitio ns\
Anyway, I'm glad that works for you! Regards, Joe
shortname.bat c:\Windows\PolicyDefinitio
Anyway, I'm glad that works for you! Regards, Joe
And if you don't want another BAT file, you can do the following at a command prompt:
»bp
for %F in ("c:\longpathname\longfilename.txt") do @echo %~sF
»bp
ASKER
Thanx!
ASKER
We found that in one of our searched, but didn't work., Seeing your example we were missing the quotes. We just finish testing and it gave us the short name of all the path we need to work with!
Thanx!