jeremyotten Posted November 11, 2008 Share Posted November 11, 2008 Ok this is the case..What I want to build is a script that reads a .txt file.the txt file has this formatLine 1 ValueA ValueB1 - ValueBetc....Line 2 ValueA ValueC1 - ValueCetc....etcWhat I want is a script to read the txt file an file the command like thisRLGRPCRT ValueA /B -member ValueB1RLGRPCRT ValueA /B -member ValueB2etcetcIf one could help me out... Link to comment Share on other sites More sharing options...
jaclaz Posted November 11, 2008 Share Posted November 11, 2008 (edited) Ok this is the case..What I want to build is a script that reads a .txt file.the txt file has this formatLine 1 ValueA ValueB1 - ValueBetc....Line 2 ValueA ValueC1 - ValueCetc....etcWhat I want is a script to read the txt file an file the command like thisRLGRPCRT ValueA /B -member ValueB1RLGRPCRT ValueA /B -member ValueB2etcetcIf one could help me out...That is not a file format description, it's a mess. How many values B2, B3, B4, BEtc are there?Fixed in all lines?Variable?Are all tokens of the same length?Do the names contain special characters like &, | + : = and the like?Is the [space] the only delimiter?Is first token ALWAYS the same "ValueA"?Why instead of trying to describe the file don't you post a few lines of that file (with names changed as to protect the innocent - if needed)?Did you ALREADY try by yourself after reading these:http://www.robvanderwoude.com/ntfor.htmlhttp://www.robvanderwoude.com/ntfortokens.htmland failed?jaclaz Edited November 11, 2008 by jaclaz Link to comment Share on other sites More sharing options...
jeremyotten Posted November 11, 2008 Author Share Posted November 11, 2008 (edited) ok I have a groups.txt and a users.txtthe command should beRLGRPCRT.exe ".Line 1 of groups.txt.APPS.GROUPS.CARE" /B (Value1 of line 1 of users.txt) /B (Value2 if line 2 of users.txt)Yes I have tried and failed :-(Extra InfoLines in groups.txt can have spaces in it.Values in lines of users.txt do not have spaces.groups.txt has 1 group per lineusers.txt has multiple users(no spaces) per lineevery line in users.txt has a random number of usersline1 of groups.txt should get all the member users of line 1 in users.txt Edited November 11, 2008 by jeremyotten Link to comment Share on other sites More sharing options...
jeremyotten Posted November 11, 2008 Author Share Posted November 11, 2008 I was able to re-use something from the robocopy script. BUT. it's not complete@Echo off&SetlocalSet "_=0"For /f "delims=" %%# In (groups.txt) Do (Set/a "_+=1"&Call :N_ %%_%% "%%#")Set "_="&Goto :Eof:N_Set "$=0"For /f "delims=" %%# In (users.txt) Do (Set/a "$+=1"&Call :O_ %%$%% "%%#" %1 %2)Set "$="&Goto :Eof:O_If %3 Equ %1 RLGRPCRT.exe "%~4" /B %~2now it outputs /B All value's while it should output /B Value1 / B Value2 etc etcValue ammount differs per line.. Link to comment Share on other sites More sharing options...
jaclaz Posted November 11, 2008 Share Posted November 11, 2008 Please post a snippet of BOTH groups.txt and users.txt.jaclaz Link to comment Share on other sites More sharing options...
jeremyotten Posted November 11, 2008 Author Share Posted November 11, 2008 Please post a snippet of BOTH groups.txt and users.txt.jaclazpart op groups.txtApp. BOApp. BusinessObjectsMedewerkers Zorgmanagers NoordDePrins MTMedewerkers Regio OostMedewerkers Zorgmanagers OostApp. FWGMedewerkers Regio WestMedewerkers Zorgmanagers Westpart of users.txtP700489 P700144 P700134 P700470 P300013 P700571 P700224 P700090 P700677 P700006 P700043 P700371 P700326 P700125P700489 P700023 P700144 P700062 P700448 P700134 P700652 P700662 P700470 P700253 P300013 P700330 P700571 P700632P700470 P700566 P700240 P700692 P700140 P700371 P700281 P700081 P700248 P700225 P700159 P700663 P700443 P700210 P700238 P700566 P700692 P700151 P700603 P700271 P700169 P700417P700238 P700566 P700692 P700271 P700417 P700051 P700678 P700238 P700040 P700566 P700240 P700692 P700277 P700541 P700371 P700146 P700140 P700271 P700097P700051 P700339 P700218 P700662 P700039 P700189 P700090 P700084 P700143 P700663 P700552 P700192 P700625 P700457P700051 P700238 P700277 P700140 P700271 P700112 Link to comment Share on other sites More sharing options...
jaclaz Posted November 11, 2008 Share Posted November 11, 2008 So these would be valid commands? RLGRPCRT.exe "App. BO" /B P700489 /B P700144 /B P700134RLGRPCRT.exe " Medewerkers Zorgmanagers Noord " /B P700489 /B P700566 /B P700240There is no problem in making a batch, but I wonder (just like for the Robocopy .script) how one is supposed to be able to verify if the groups.txt and the users.txt are "in sync".Depending on lenght of line (i.e. how many tokens there are in users.txt) this may work:@ECHO OFFSETLOCAL ENABLEEXTENSIONSSETLOCAL ENABLEDELAYEDEXPANSIONSET /A n=-1FOR /F "delims=" %%A in (groups.txt) DO (SET This_group="%%A"CALL :Parse_usersECHO RLGRPCRT.exe !This_group! /B !These_users!)GOTO :EOF:Parse_usersSET /A n+=1FOR /F "delims=" %%B in ('MORE +%n% users.txt' ) DO (SET These_users=%%BSET These_users=!These_users: = /B !GOTO :EOF)jaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted November 11, 2008 Share Posted November 11, 2008 Quick reply on passing...Changing the `robocopy script` to look something like this would probably do it!@Echo off&SetlocalSet "_=0"For /f "delims=" %%# In (users.txt) Do ( Set/a "_+=1"&Call :N_ %%_%% "%%#")Set "_="&Goto :Eof:N_Set "$=0"For /f "delims=" %%# In (groups.txt) Do ( Set/a "$+=1"&Call :O_ %%$%% "%%#" %1 %2)Set "$="&Goto :Eof:O_If %3 Neq %1 Goto :EofSet "£=%~4"Set "£=/B %£: = /B %"RLGRPCRT.exe ".%~2.APPS.GROUPS.CARE" %£%It may also be necessary depending upon the commandline utility you're using to use Start "" /wait in order to ensure completion of each command line prior to the next one starting. Link to comment Share on other sites More sharing options...
jeremyotten Posted November 12, 2008 Author Share Posted November 12, 2008 Quick reply on passing...Changing the `robocopy script` to look something like this would probably do it!@Echo off&SetlocalSet "_=0"For /f "delims=" %%# In (users.txt) Do ( Set/a "_+=1"&Call :N_ %%_%% "%%#")Set "_="&Goto :Eof:N_Set "$=0"For /f "delims=" %%# In (groups.txt) Do ( Set/a "$+=1"&Call _ %%$%% "%%#" %1 %2)Set "$="&Goto :Eof_If %3 Neq %1 Goto :EofSet "£=%~4"Set "£=/B %£: = /B %"RLGRPCRT.exe ".%~2.APPS.GROUPS.CARE" %£%It may also be necessary depending upon the commandline utility you're using to use Start "" /wait in order to ensure completion of each command line prior to the next one starting.the GOD has returned ;-)only it works almost.users.txtP700532 P700348 P700100 P700078 P700449 P700493 P700294 P700015 P700276 P700343 P700263 P700479 P700472 P700435 P700419 P700245 P700220 P700287 P700135 P700566 P700376 P700310 P700607 P700092 P700653 P700511P700470 P700632 P700566 P700240 P700470 P700632 P700566 P700240 P700140 P700511groups.txtFS03 ClientdoFS03 LeesClientDoFS03 PersBestI get this error logError! .FS03 Clientdo.DEPT.GROUPS.CAG.META - Switch P700511 needs an argument.Error! .FS03 LeesClientDo.DEPT.GROUPS.CAG.META - Switch P700240 needs an argument.Error! .FS03 PersBest.DEPT.GROUPS.CAG.META - Switch P700511 needs an argument.So it looks like every last P number per line doesn''t get the /B in front of it... :-( Link to comment Share on other sites More sharing options...
jeremyotten Posted November 12, 2008 Author Share Posted November 12, 2008 Quick reply on passing...Changing the `robocopy script` to look something like this would probably do it!@Echo off&SetlocalSet "_=0"For /f "delims=" %%# In (users.txt) Do ( Set/a "_+=1"&Call :N_ %%_%% "%%#")Set "_="&Goto :Eof:N_Set "$=0"For /f "delims=" %%# In (groups.txt) Do ( Set/a "$+=1"&Call _ %%$%% "%%#" %1 %2)Set "$="&Goto :Eof_If %3 Neq %1 Goto :EofSet "£=%~4"Set "£=/B %£: = /B %"RLGRPCRT.exe ".%~2.APPS.GROUPS.CARE" %£%It may also be necessary depending upon the commandline utility you're using to use Start "" /wait in order to ensure completion of each command line prior to the next one starting.the GOD has returned ;-)only it works almost.users.txtP700532 P700348 P700100 P700078 P700449 P700493 P700294 P700015 P700276 P700343 P700263 P700479 P700472 P700435 P700419 P700245 P700220 P700287 P700135 P700566 P700376 P700310 P700607 P700092 P700653 P700511P700470 P700632 P700566 P700240 P700470 P700632 P700566 P700240 P700140 P700511groups.txtFS03 ClientdoFS03 LeesClientDoFS03 PersBestI get this error logError! .FS03 Clientdo.DEPT.GROUPS.CAG.META - Switch P700511 needs an argument.Error! .FS03 LeesClientDo.DEPT.GROUPS.CAG.META - Switch P700240 needs an argument.Error! .FS03 PersBest.DEPT.GROUPS.CAG.META - Switch P700511 needs an argument.So it looks like every last P number per line doesn''t get the /B in front of it... :-(nevermind the script works you are the GOD!! ;-)problem was with TABS when copied from excel to notepad Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now