troubleshooting Question

Change String with Windows Batch Script

Avatar of jskfan
jskfanFlag for Cyprus asked on
Windows BatchWindows OS
13 Comments2 Solutions95 ViewsLast Modified:
Change String with Windows Batch  Script

I have a CSV file that has computer names, usernames

computername, Newusername 
comp1,  John
CompX, Alton

in each computer C: drive there is a text file (C:\test.txt) that has  a line like this :
aaaaaaaa                  bbbbbbbbbbb        ccccccccccc   -username    username

I want the second username string to be replaced by a string read from the CSV file under usernames ... Note the first username has a dash in front of it and it should stay as it is -username, I need just the second username to be changed.

for instance:
 on comp1 , the line will be
aaaaaaaa                  bbbbbbbbbbb        ccccccccccc   -username    John

 on compX , the line will be
aaaaaaaa                  bbbbbbbbbbb        ccccccccccc   -username    Alton

Thank you
"Batchelor", Developer and EE Topic Advisor

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2015

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 2 Answers and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros