Solved

Batch script: echo each path in new line

Posted on 2006-06-15
6
1,932 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:gromul
  • 4
  • 2
6 Comments
 

Author Comment

by:gromul
Comment Utility
Path can have one or more items
0
 

Author Comment

by:gromul
Comment Utility
More specifically, 2+
0
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
Assuming there are no semicolons in a path statement (it could theoretically happen ...), the following should work:

set Tail=%Path%
:loop
for /f "tokens=1* delims=;" %%a in ("%Tail%") do (
  echo %%a
  set Tail=%%b
  if not "%%b"=="" goto :loop
)
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

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

path1;path2;path3
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
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 ...
0
 

Author Comment

by:gromul
Comment Utility
All right. Thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like 192.168.xxx.1, I've seen routers with default values of: 192.168.0.1, 192.168.1.1, 192.168.11.1, …
If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now