Bat file to echo list of computers

I am trying to make a bat file that will list all the computers turned on in my building.   They are all part of the same domain.  I can create the list but I am also trying to format the list so that only the computer names show up, one name on each line with no spaces.  I used the command "net view" to list all the computers turned on, on the domain. Then I use the find command to list only the computers I am looking for.  Then I need to remove all the "\\"  and all the white spaces.  Can you help me with this?  Im using windows 7 computers.  
net view > x.txt
find /I "CRL" x.txt > z.txt

Open in new window

Who is Participating?
Bill PrewCommented:
Here's a small BAT script that should do the job:

@echo off
setlocal EnableDelayedExpansion
if exist "z.txt" del "z.txt"
for /F "tokens=1" %%A in ('net view ^|find /I "CRL"') do (
  set PC=%%A
  echo !PC:\\=!>>"z.txt"

Open in new window

There is a command line utilty called bsed.exe that works very much like sed in unix.  It will allow you to search and replace.

ForLoop5Author Commented:
That worked great.  Thank you!
Bill PrewCommented:
Very welcome, glad that helped.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.