# bulk edit csv file with batch file or script

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

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

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.

IT ManagerCommented:
Give this a shot
OM Gang

Option Explicit

Dim objFSO, objFile, objTempFile
Dim intFirstComma, intSecondComma

Const FilePath = "C:\test2\text5.csv"
Const ForWriting = 2

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

Do Until objFile.AtEndOfStream
'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
Loop

objFile.Close
objTempFile.Close

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

0

Experts Exchange Solution brought to you by

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

IT ManagerCommented:
This is the result after the script is run