Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Using the dsquery command I create lists of what groups a user has. This looks something like this:
"CN=App1,OU=User Groups,OU=Unit,DC=directory,DC=local"
"CN=App2,OU=User Groups,OU=Unit,DC=directory,DC=local"
"CN=Domain Server Ops,OU=Migrate Groups,OU=User Groups,OU=Unit,DC=directory,DC=local"
"CN=Domain Account Ops,OU=Migrate Groups,OU=User Groups,OU=Unit,DC=directory,DC=local"I want this output to be put in one line, divided bij a semicolon (;). How can I accomplish this in cmd?

@echo off > newfile
setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in (myfile) do (
set s=!s!%%a;
)
echo !s:~0,-1!>> newfile
=====================================
If at first you don't succeed, you're about average.M2

Nice! Works great!
What if I'd want to keep the multiple lines but add a set variable in front of each line, followed by the semicolon and the rest of the line?

@echo off > newfile
setLocal EnableDelayedExpansionset myvar=this
for /f "tokens=* delims= " %%a in (myfile) do (
echo !myvar!%%a;>>newfile
)
=====================================
If at first you don't succeed, you're about average.M2

![]() |
Help! PC can't boot-up, p...
|
different desktop?
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |