batch file - Getting a for loop working -


i'm trying split apart system path variable batch. have:

@echo off setlocal enabledelayedexpansion set npath=%path% set i=0 echo %npath% > temp /f "delims=;" %%a in (temp) (     echo [!i!]: %%a     set /a i=!i!+1 ) 

when runs, however, runs loop single time. instead of expected output, list of directories in path, outputs single one:

stupid lazy batch

what's happening? doing wrong? i've tried using path string, i've tried changing number of tokens, i've tried everything. not understand how loops work in batch?

try iterate items in path plain loop (and need set quotes prevent space collisions):

@echo off  setlocal enabledelayedexpansion set "_path="!path:;=" "!"" rem echo %_path% set i=0 %%a in (%_path%) (     echo [!i!]: %%~a     set /a i=!i!+1 ) endlocal 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -