Echo %path% on separate lines?

Carl R picture Carl R · Feb 25, 2011 · Viewed 60k times · Source

Using the windows command prompt, can I echo %path% and get the resulting paths on separate rows? Something like this but for windows:

echo $path | tr ':' '\n'

Can I do this with vanilla cmd or do I need powershell or js scripting?

Example echo %path% output:

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;

Desired output:

C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;
C:\Program Files\Microsoft SQL Server\90\Tools\binn\;
C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;

Answer

Ekkehard.Horner picture Ekkehard.Horner · Feb 25, 2011

Try:

 ($env:Path).Replace(';',"`n")

or

$env:path.split(";")