I need help with a batch file that will read from a single file called “Userlist.txt” and then create another file based on that list.I have some of it already but I’m stuck on getting the first token to be listed on the same line in the “addusers.txt” file instead of on separate lines.
The “Userslist.txt file should look like this:
*********Userlist.txt file***********
Joeuser1,Joe Blow, P@ssw0rd,Information about Joe 1
joeuser2,Joe Blow, P@ssw0rd,Information about Joe 2
joeuser2,Joe Blow, P@ssw0rd,Information about Joe 3
*********Userlist.txt file***********
I want to be able to dynamically create an adduser.txt file using the information from the userlist.txt file. The “Adduser.txt file should look like this:
*********Begin Adduser.txt file***********
[USERS]
Joeuser1,Joe Blow, P@ssw0rd,Information about Joe 1
joeuser2,Joe Blow, P@ssw0rd,Information about Joe 2
joeuser2,Joe Blow, P@ssw0rd,Information about Joe 3
[local]
Administrators,,joeuser1,joeuser2,joeuser3
Engineers,,joeuser1,joeuser2,joeuser3
********End Adduser.txt file***************
Currently I have test.bat file
**********Begin test.bat*************
@echo off
Cls
Rem This portion of the script creates the adduserslist.txt file, but I don’t know how to create the
echo [USERS] > D:\Maintenance\adduserlist.txt
for /f "tokens=*" %%A in (D:\Maintenance\Userlist.txt) do (
echo %%A >> D:\Maintenance\adduserlist.txt
)
echo [local] >> D:\Maintenance\adduserlist.txt
echo Administrators, >> D:\Maintenance\adduserlist.txt
for /f "tokens=1 delims=," %%a in (D:\Maintenance\Userlist.txt) do (
echo ,%%a >> D:\Maintenance\adduserlist.txt
)
echo Engineers, >> D:\Maintenance\adduserlist.txt
for /f "tokens=1 delims=," %%a in (D:\Maintenance\Userlist.txt) do (
echo ,%%a >> D:\Maintenance\adduserlist.txt
)
rem d:\Maintenance\addusers /c d:\Maintenance\adduserlist.txt
*******End test.bat file*************