Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Batch script: echo each path in new line

Posted on 2006-06-15
6
1,942 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
ID: 16915693
Path can have one or more items
0
 

Author Comment

by:gromul
ID: 16915695
More specifically, 2+
0
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 16921540
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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:gromul
ID: 16924349
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 84

Expert Comment

by:oBdA
ID: 16926527
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
ID: 16936528
All right. Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
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, …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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