modify vbs

Home Forums Scripting General Scripting modify vbs

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    ekrengel
    Member
    #126035

    I have a script that reads from a .ldf file, and sorts the data out into a text file. Here is the format it reads from:

    CN=Lastname, Firstname,OU=Users,OU=sports group,DC=domain,DC=name, DC=com[/CODE]

    This code will read the data and sort it:

    [CODE]Dim objFileSystem, objInputFile
    Dim strOutputFile, inputData, strData, strTemp

    Const OPEN_FILE_FOR_READING = 1

    ‘ generate a filename base on the script name, here readfile.in
    strOutputFile = “groups.ldf”

    Set objFileSystem = CreateObject(“Scripting.fileSystemObject”)
    Set objInputFile = objFileSystem.OpenTextFile(strOutputFile, OPEN_FILE_FOR_READING)

    ‘ read everything in an array
    inputData = Split(objInputFile.ReadAll, vbNewline)

    For each strData In inputData
    if Mid(strData, 1,2)=”me” and len(strdata)>10 then
    strTemp=Mid(strData, 12, InStr(1, strData,”,”,1)-12)

    WScript.Echo strTemp

    end if

    if Mid(strData,1,2)=” C” then

    strTemp=Mid(strData, 5, InStr(1, strData,”,”,1)-5)

    WScript.Echo strTemp
    end if

    Next

    objInputFile.Close
    Set objFileSystem = Nothing

    WScript.Quit(0)[/CODE]

    In the text file it looks like this:

    Lastname

    How would I modify the code to make the output “Lastname, Firstname” instead of “Lastname”? I don’t know where to start to edit this.

    Thanks to anyone who can help…[CODE]CN=Lastname, Firstname,OU=Users,OU=sports group,DC=domain,DC=name, DC=com[/CODE]

    This code will read the data and sort it:

    Dim objFileSystem, objInputFile
    Dim strOutputFile, inputData, strData, strTemp

    Const OPEN_FILE_FOR_READING = 1

    ‘ generate a filename base on the script name, here readfile.in
    strOutputFile = “groups.ldf”

    Set objFileSystem = CreateObject(“Scripting.fileSystemObject”)
    Set objInputFile = objFileSystem.OpenTextFile(strOutputFile, OPEN_FILE_FOR_READING)

    ‘ read everything in an array
    inputData = Split(objInputFile.ReadAll, vbNewline)

    For each strData In inputData
    if Mid(strData, 1,2)=”me” and len(strdata)>10 then
    strTemp=Mid(strData, 12, InStr(1, strData,”,”,1)-12)

    WScript.Echo strTemp

    end if

    if Mid(strData,1,2)=” C” then

    strTemp=Mid(strData, 5, InStr(1, strData,”,”,1)-5)

    WScript.Echo strTemp
    end if

    Next

    objInputFile.Close
    Set objFileSystem = Nothing

    WScript.Quit(0)[/CODE]

    In the text file it looks like this:

    Lastname

    How would I modify the code to make the output “Lastname, Firstname” instead of “Lastname”? I don’t know where to start to edit this.

    Thanks to anyone who can help…[CODE]Dim objFileSystem, objInputFile
    Dim strOutputFile, inputData, strData, strTemp

    Const OPEN_FILE_FOR_READING = 1

    ‘ generate a filename base on the script name, here readfile.in
    strOutputFile = “groups.ldf”

    Set objFileSystem = CreateObject(“Scripting.fileSystemObject”)
    Set objInputFile = objFileSystem.OpenTextFile(strOutputFile, OPEN_FILE_FOR_READING)

    ‘ read everything in an array
    inputData = Split(objInputFile.ReadAll, vbNewline)

    For each strData In inputData
    if Mid(strData, 1,2)=”me” and len(strdata)>10 then
    strTemp=Mid(strData, 12, InStr(1, strData,”,”,1)-12)

    WScript.Echo strTemp

    end if

    if Mid(strData,1,2)=” C” then

    strTemp=Mid(strData, 5, InStr(1, strData,”,”,1)-5)

    WScript.Echo strTemp
    end if

    Next

    objInputFile.Close
    Set objFileSystem = Nothing

    WScript.Quit(0)[/CODE]

    In the text file it looks like this:

    Lastname

    How would I modify the code to make the output “Lastname, Firstname” instead of “Lastname”? I don’t know where to start to edit this.

    Thanks to anyone who can help…

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.