@echo off REM REM pathos.bat by Eli Fulkerson, 2011 REM http://www.elifulkerson.com/projects for updates REM REM Bash search and replace cribbed from http://stackoverflow.com/questions/1707058/how-to-split-a-string-in-a-windows-batch-file/4746417#4746417 if "%1"=="+" GOTO ADD if "%1"=="-" GOTO DEL if "%1"=="s" GOTO SAVE if "%1"=="l" GOTO LOAD if "%1"=="?" GOTO HELP :HELP echo Usage: pathos [+/-/s/l] directory [directory2... ..directory8] echo "pathos + ." will add the expanded . to the path. echo "pathos - ." will remove the expanded . from the path. echo "pathos +" accepts between 1 and 8 arguments. echo "pathos -" accepts only one argument echo "pathos s" saves the current path to the variable PATHOSPATH echo "pathos l" replaces the current path with the value in PATHOSPATH, if defined goto END :SAVE set PATHOSPATH=%PATH% goto END :LOAD if not defined PATHOSPATH goto NOLOAD set PATH=%PATHOSPATH% :NOLOAD goto END :ADD IF NOT "%~f2"=="" PATH=%PATH%;%~f2 IF NOT "%~f3"=="" PATH=%PATH%;%~f3 IF NOT "%~f4"=="" PATH=%PATH%;%~f4 IF NOT "%~f5"=="" PATH=%PATH%;%~f5 IF NOT "%~f6"=="" PATH=%PATH%;%~f6 IF NOT "%~f7"=="" PATH=%PATH%;%~f7 IF NOT "%~f8"=="" PATH=%PATH%;%~f8 IF NOT "%~f9"=="" PATH=%PATH%;%~f9 goto END :DEL setlocal ENABLEDELAYEDEXPANSION set teststring=%path% set ACCUM= :stringloop if "!teststring!" EQU "" goto ENDDEL for /f "delims=;" %%a in ("!teststring!") do set substring=%%a if "!substring!" EQU "" GOTO NOADD if "!substring!" NEQ "%~f2" set ACCUM=%ACCUM%;!substring! :NOADD REM echo acc is now !ACCUM! REM echo !substring! :striploop set stripchar=!teststring:~0,1! set teststring=!teststring:~1! if "!teststring!" EQU "" goto stringloop if "!stripchar!" NEQ ";" goto striploop goto stringloop ) :ENDDEL set stripchar=!ACCUM:~0,1! if "!stripchar!" NEQ ";" goto DONT_STRIP_LEFT set ACCUM=!ACCUM:~1! :DONT_STRIP_LEFT endlocal&set path=%ACCUM% goto END :END