Created
December 26, 2016 23:29
-
-
Save Brainiarc7/0df2baf74a9eead7690112b7c1b4b5f2 to your computer and use it in GitHub Desktop.
Windows Batch %PATH% Environment Variable Shortener and Checker
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
| REM In a command shell save output to a text file | |
| REM e.g. C:\Users\myname\Desktop\ PathShortener.cmd > output.txt | |
| REM Review output, then replace current %PATH% variable | |
| REM This handy script was found online, unfortunately the original | |
| REM author isn't credited here. | |
| @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