bulk edit csv file with batch file or script

I have a file that i am exporting that looks like:

first, last, grade

john, doe, 8
jane, smith, 12
jess, jones, 9

This file with have a couple 100 records in it.  This file will also get create everynight with update info.  I have a need to bulk modify this file so it looks something like

first, last, grade, username, password

john, doe, 8, acme-jdoe, Password
jane, smith, 12, acme-jsmith, Password
jess, jones, 9, acme-jjones, Password

How can i automatically bulk edit the original file to add the username and password for each record.  The password will be the same for all users.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omgangIT ManagerCommented:
Give this a shot
OM Gang

Option Explicit

Dim objFSO, objFile, objTempFile
Dim strLine, strFI, strLName, strUserName
Dim intFirstComma, intSecondComma

Const FilePath = "C:\test2\text5.csv"
Const ForReading = 1
Const ForWriting = 2
Const Password = "ThisIsThePassword"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(FilePath, ForReading)
Set objTempFile = objFSO.OpenTextFile("C:\test2\temp5.csv", ForWriting, True)

Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
	'get first initial
    strFI = Left(strLine, 1)
	'get last name
    intFirstComma = InStr(strLine, ",")
    intSecondComma = InStr(intFirstComma + 1, strLine, ",")
    strLName = Trim(Mid(strLine, intFirstComma + 1, intSecondComma - intFirstComma - 1))

    strUserName = "acme-" & strFI & strLName

        'write to temp file
    strLine = strLine & ", " & strUserName & ", " & Password
    objTempFile.WriteLine strLine


objFSO.MoveFile "c:\test2\temp5.csv", FilePath

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omgangIT ManagerCommented:
This is the result after the script is run

john, doe,8, acme-jdoe, ThisIsThePassword
jane, smith,12, acme-jsmith, ThisIsThePassword
jess, jones,9, acme-jjones, ThisIsThePassword

OM Gang
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.