Jump to content

Script guru needed!


Recommended Posts

Ok this is the case..

What I want to build is a script that reads a .txt file.

the txt file has this format

Line 1 ValueA ValueB1 - ValueBetc....

Line 2 ValueA ValueC1 - ValueCetc....

etc

What I want is a script to read the txt file an file the command like this

RLGRPCRT ValueA /B -member ValueB1

RLGRPCRT ValueA /B -member ValueB2

etc

etc

If one could help me out...

Link to comment
Share on other sites


Ok this is the case..

What I want to build is a script that reads a .txt file.

the txt file has this format

Line 1 ValueA ValueB1 - ValueBetc....

Line 2 ValueA ValueC1 - ValueCetc....

etc

What I want is a script to read the txt file an file the command like this

RLGRPCRT ValueA /B -member ValueB1

RLGRPCRT ValueA /B -member ValueB2

etc

etc

If one could help me out...

That is not a file format description, it's a mess. :w00t:

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.html

http://www.robvanderwoude.com/ntfortokens.html

and failed?

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

ok I have a groups.txt and a users.txt

the command should be

RLGRPCRT.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 Info

Lines in groups.txt can have spaces in it.

Values in lines of users.txt do not have spaces.

groups.txt has 1 group per line

users.txt has multiple users(no spaces) per line

every line in users.txt has a random number of users

line1 of groups.txt should get all the member users of line 1 in users.txt

Edited by jeremyotten
Link to comment
Share on other sites

I was able to re-use something from the robocopy script. BUT. it's not complete

@Echo off&Setlocal
Set "_=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 %~2

now it outputs /B All value's while it should output /B Value1 / B Value2 etc etc

Value ammount differs per line..

Link to comment
Share on other sites

Please post a snippet of BOTH groups.txt and users.txt.

jaclaz

part op groups.txt

App. BO

App. BusinessObjects

Medewerkers Zorgmanagers Noord

DePrins MT

Medewerkers Regio Oost

Medewerkers Zorgmanagers Oost

App. FWG

Medewerkers Regio West

Medewerkers Zorgmanagers West

part of users.txt

P700489 P700144 P700134 P700470 P300013 P700571 P700224 P700090 P700677 P700006 P700043 P700371 P700326 P700125

P700489 P700023 P700144 P700062 P700448 P700134 P700652 P700662 P700470 P700253 P300013 P700330 P700571 P700632

P700470 P700566 P700240 P700692 P700140

P700371 P700281 P700081

P700248 P700225 P700159 P700663 P700443 P700210 P700238 P700566 P700692 P700151 P700603 P700271 P700169 P700417

P700238 P700566 P700692 P700271 P700417

P700051 P700678 P700238 P700040 P700566 P700240 P700692 P700277 P700541 P700371 P700146 P700140 P700271 P700097

P700051 P700339 P700218 P700662 P700039 P700189 P700090 P700084 P700143 P700663 P700552 P700192 P700625 P700457

P700051 P700238 P700277 P700140 P700271 P700112

Link to comment
Share on other sites

So these would be valid commands? :unsure:

RLGRPCRT.exe "App. BO" /B P700489 /B P700144 /B P700134

RLGRPCRT.exe " Medewerkers Zorgmanagers Noord " /B P700489 /B P700566 /B P700240

There 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 OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

SET /A n=-1
FOR /F "delims=" %%A in (groups.txt) DO (
SET This_group="%%A"
CALL :Parse_users

ECHO RLGRPCRT.exe !This_group! /B !These_users!

)
GOTO :EOF

:Parse_users
SET /A n+=1
FOR /F "delims=" %%B in ('MORE +%n% users.txt' ) DO (
SET These_users=%%B
SET These_users=!These_users: = /B !
GOTO :EOF
)

jaclaz

Link to comment
Share on other sites

Quick reply on passing...

Changing the `robocopy script` to look something like this would probably do it!

@Echo off&Setlocal
Set "_=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 :Eof
Set "£=%~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

Quick reply on passing...

Changing the `robocopy script` to look something like this would probably do it!

@Echo off&Setlocal
Set "_=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 :Eof
Set "£=%~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.txt

P700532 P700348 P700100 P700078 P700449 P700493 P700294 P700015 P700276 P700343 P700263 P700479 P700472 P700435 P700419 P700245 P700220 P700287 P700135 P700566 P700376 P700310 P700607 P700092 P700653 P700511

P700470 P700632 P700566 P700240

P700470 P700632 P700566 P700240 P700140 P700511

groups.txt

FS03 Clientdo

FS03 LeesClientDo

FS03 PersBest

I get this error log

Error! .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

Quick reply on passing...

Changing the `robocopy script` to look something like this would probably do it!

@Echo off&Setlocal
Set "_=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 :Eof
Set "£=%~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.txt

P700532 P700348 P700100 P700078 P700449 P700493 P700294 P700015 P700276 P700343 P700263 P700479 P700472 P700435 P700419 P700245 P700220 P700287 P700135 P700566 P700376 P700310 P700607 P700092 P700653 P700511

P700470 P700632 P700566 P700240

P700470 P700632 P700566 P700240 P700140 P700511

groups.txt

FS03 Clientdo

FS03 LeesClientDo

FS03 PersBest

I get this error log

Error! .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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...