Solved

Batch script: echo each path in new line

Posted on 2006-06-15
6
1,937 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 83

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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 83

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ROOT\*0700\1_0_13_0_0_0 8 147
netsh interface ip show interface in Windows XP 4 125
how to Repair Windows XP 12 94
no display on laptop 5 79
Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
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, …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

776 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