Created
March 18, 2011 19:58
-
-
Save dolmen/876725 to your computer and use it in GitHub Desktop.
A procedure that call a callback for each directory of %PATH%
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 | |
:: Copyright © 2011 Olivier Mengué | |
:: License GNU GPL 3.0 | |
setlocal | |
call :VisitPATH :Echo | |
goto :EOF | |
:Echo | |
echo.[%~1] | |
echo %PATH% | |
goto :EOF | |
:: VisitPATH | |
:: | |
:: %1 callback name | |
:: | |
: == VisitPATH == | |
:: Save PATH | |
set VisitPATH_P=%PATH% | |
call :VisitPATH_Loop %1 . | |
goto :EOF | |
:VisitPATH_Loop | |
set VisitPATH_Q=%PATH% | |
:: Find the first "." in the reduced %PATH% => first directory in %PATH% | |
set PATH=%VisitPATH_P%& call %1 "%~$PATH:2" | |
set PATH=%VisitPATH_Q:*;=% | |
if not "%PATH%"=="%VisitPATH_Q%" goto :VisitPATH_Loop | |
set PATH=%VisitPATH_P% | |
set VisitPATH_P= | |
set VisitPATH_Q= | |
goto :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment