Link to home
Start Free TrialLog in
Avatar of gromul
gromul

asked on

Batch script: echo each path in new line

I need a batch script that would echo each path in a new line. So far I have this which echoes all the paths in the same line:

FOR /F "tokens=* delims=;" %%A IN ('ECHO %path%') DO echo %%A

Thanks
Avatar of gromul
gromul

ASKER

Path can have one or more items
Avatar of gromul

ASKER

More specifically, 2+
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gromul

ASKER

What do you mean "there are no semicolons in a path statement"? My path (echo %path%) looks something like this:

path1;path2;path3
That's okay, in that case, it's the regular delimiter for the different paths.
But theoretically, a semicolon could be part of a directory path:
%systemroot%\system32;%systemroot%;"C:\Some\Folder\with a ; in it";C:\Program Files\Acme
That's when it gets ugly, because the "for" command wouldn't care about the quotation marks around the directory, and break it up to
%systemroot%\system32
%systemroot%
"C:\Some\Folder\with a
in it"
C:\Program Files\Acme
Not that i can remember having ever come across a folder name with a semicolon in it, and it's even less likely for it to appear in a system's path, but just for the sake of completeness, it should be mentioned ...
Avatar of gromul

ASKER

All right. Thanks!