Category : Files from Magazines
Archive   : V12N16.ZIP
Filename : PE.BAT

 
Output of file : PE.BAT contained in archive : V12N16.ZIP

@ECHO OFF
:PE.BAT - Path Editor. Add or remove directories
IF '%2'=='' GOTO Help
IF '%1'=='+' GOTO AddEnd
IF '%1'=='&' GOTO AddBegin
IF '%1'=='-' GOTO Drop
IF '%1'=='¬' GOTO DoDrop
GOTO Help

:===== AddEnd ========
PATH=%PATH%;%2
ECHO %2 added at end of path.
GOTO End

:===== AddBegin ======
PATH=%2;%PATH%
ECHO %2 added at beginning of path.
GOTO End

:===== Drop ==========
SET ¬=%PATH%
PATH=%2
SET PE_drop=%path%
:: Now variable drop contains %2 capitalized
PATH=%¬%
SET ¬=
SET PE_rem=
:: Restart, passing PATH as parameters
%0 ¬ %PATH%

:===== DoDrop ========
SET PATH=
:== DropLoop
SHIFT
IF '%1'=='' GOTO DoneDrop
IF '%1'=='%PE_drop%' GOTO DidRemove
IF '%PATH%'=='' PATH=%1
IF '%PATH%'=='%1' GOTO DropLoop
PATH=%PATH%;%1
GOTO DropLoop
:== DidRemove
SET PE_rem=YES
GOTO DropLoop

:===== DoneDrop ======
IF '%PE_rem%'=='' ECHO %PE_drop% not found
IF '%PE_rem%'=='YES' ECHO %PE_drop% removed from path
SET PE_drop=
SET PE_rem=
GOTO End

:===== Help ==========
ECHO The options are:
ECHO %0 + directory : adds directory at end of path
ECHO %0 & directory : adds directory at start of path
ECHO %0 - directory : drops directory from path
ECHO Note that the PATH must not be empty.

:===== End ===========
PATH