Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Batch script: echo each path in new line

Posted on 2006-06-15
6
Medium Priority
?
1,985 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 85

Accepted Solution

by:
oBdA earned 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 85

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

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…
Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 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