Created
December 4, 2015 15:21
-
-
Save ryanwischkaemper/19918bcb3c216b670298 to your computer and use it in GitHub Desktop.
This will parse your %PATH% environment variable and convert each directory to its shortname equivalent and then piece it all back together. Use the output to replace current PATH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
SET MyPath=%PATH% | |
echo %MyPath% | |
echo -- | |
setlocal EnableDelayedExpansion | |
SET TempPath="%MyPath:;=";"%" | |
SET var= | |
FOR %%a IN (%TempPath%) DO ( | |
IF exist %%~sa ( | |
SET "var=!var!;%%~sa" | |
) ELSE ( | |
echo %%a does not exist | |
) | |
) | |
echo -- | |
echo !var:~1! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment