Search code examples
windowsbatch-filecommand-line-interfacebatch-processing

Loop through folder names via %PATH%


I'm expecting to get all folders stated in %PATH%, yet I get only the first one. What is missing to get desired output?

for /f "delims=;" %%G in ("%PATH%") DO (
  echo %%G
)

Solution

  • Try with:

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