Sign in to follow this  
Followers 0
svss

extracting txt file info

6 posts in this topic

Hi,

i have a text file which generates a list of usernames from a command in Windows.

Every user is visible in this text file on a seperate line.

I would like to parse this info for each user into another text file.

The username should be parsed at a specific place in the second txt file so that i can run a

specific command on this 2nd text file.

So for every username i need to amend to this 2nd text file.

Could someone help me with this one?

I start to tear my hair out.

Thanks in advance

S.

Share this post


Link to post
Share on other sites



Hi,

i have a text file which generates a list of usernames from a command in Windows.

Every user is visible in this text file on a seperate line.

I would like to parse this info for each user into another text file.

The username should be parsed at a specific place in the second txt file so that i can run a

specific command on this 2nd text file.

So for every username i need to amend to this 2nd text file.

Could someone help me with this one?

I start to tear my hair out.

Thanks in advance

S.

Based off the limited information you have given us it would be difficult for us to help you. How about some examples of the text files and an example of the end result.

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Sorry about this,

please see attached username file and file2 where these usernames should be added/replaced.

So in txt file 2 the entry XYZ should be replaced with the username.

And for every username i need to amend this info to the text file.

The purpose once i run the new file all users are getting transfred to the new

Exchange server.

Any questions let me know.

thx again

S.

members2.txt

Share this post


Link to post
Share on other sites

There are numerous ways to handle strings.

An easy way would be to create the file over again, if the syntax is repeatable except for the "xyz". Read file 1 getting the name, FileWriteLine to file 2, inserting the file 1 line text into the "xyz" spot. Move on to next "xyz" read and write. Add Header or Footer text before or after the "xyz" routine.

You could also grab the name from file 1, and do a StringInStr search for ",CN=Users,DC=vebnet,DC=com", and then edit that line to include the "xyz", providing all data is repeatable.

Or a host of other ways.

Sul.

Share this post


Link to post
Share on other sites

Is this something like what you are looking for?

Const $ForReading = 0, $ForAppending = 1, $ForWriting = 2, $EachString = 0, $WholeString = 1
Const $Leading = 1, $Trailing = 2
$file1 = @ScriptDir & "\textFile1.txt"
$file2 = @ScriptDir & "\textFile2.txt"
$combined = @ScriptDir & "\output.txt"

$combinedH = FileOpen($combined, $ForWriting)

$Users = FileRead($file1, FileGetSize($file1))
$UsersA = StringSplit($Users, @CRLF, $WholeString)
$Template = FileRead($file2, FileGetSize($file2))
$TemplateA = StringSplit($Template, "CN=XYZ", $WholeString)

For $i = 1 to $UsersA[0]
    $CurrUser = StringStripWS($UsersA[$i], $Leading + $Trailing)
    $line = $TemplateA[1]
    If $TemplateA[0] > 1 Then
        For $j = 2 to $TemplateA[0]
            $line = $line & "CN=" & $CurrUser & $TemplateA[$j]
        Next
    EndIf
    FileWriteLine($combinedH, $line)
Next
FileClose($combinedH)

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Excellent guys,

works like a treat.

Much appreciated

S.

Share this post


Link to post
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
Sign in to follow this  
Followers 0