Monday, 15 June 2015

for loop - windows %PATH% variable - how to split on ';' in CMD shell again -



for loop - windows %PATH% variable - how to split on ';' in CMD shell again -

i checked stackoverflow seemed helpful , worked fine on windows xp. using windows 7 not work obscure reason.

the path variable looks this

c:\program files (x86)\nvidia corporation\physx\common;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\program files (x86)\quicktime\qtsystem\

it contains \ semicolons utilize split in batch contains for-loop:

/f "delims=;" %%a in ("%path%") ( echo %%a )

executing not cause error provides 1 (the first) token

c:\program files (x86)\nvidia corporation\physx\common

i had no thought why terminates , played around several variations have been suggested on net none did job.

any help highly appreciated.

christian

you way.

for %%a in ("%path:;=";"%") ( echo %%~a )

(source)

the problem way have that, using for /f switch, %%a specifies first token. have for /f "tokens=1-9 delims=;" %%a in ("%path%") , read in %%a through %%i way.

windows for-loop batch-file path cmd

No comments:

Post a Comment