Created
September 14, 2015 18:39
-
-
Save Spinarooni/4a3c874419a01f24f1b2 to your computer and use it in GitHub Desktop.
Script to compress file paths in PATH variable in Windows OS. Use when path length is being exceeded. Does not update the actual OS path but allows you to copy and paste it.
This file contains 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