Solved

Searching for and Changing a record in a file

Posted on 2008-10-30
2
157 Views
Last Modified: 2010-04-21
Hi all

I have a windows batch problem. I am calling in parameters from an input file.

I have a lot of entries that are colon delimited and I want to either a pull the record out or 2 change the entry.

so lets say the file is

A:1
B:2
C:3
D:44

I want to call the value for D:So I want anything right of that.. so 44 in this case.
or I want to set/change the value of C (for example) to 66, so the file looks like

A:1
B:2
C:66
D:44

Any help would be appreciated.
0
Comment
Question by:mateinone
2 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 250 total points
ID: 22847476
This should do it...
Set NewFile="C:\NewFile.txt"
for /f "tokens=1,2 delims=:" %%a in (c:\yourfile.txt) do (
  if /i [%%a]==[C] (
    echo %%a:66 >> %NewFile%
  ) else (
    echo %%a:%%b
  )
)

Open in new window

0
 
LVL 1

Author Closing Comment

by:mateinone
ID: 31511935
It was not exactly the thing I was after, but that may have been due to the question, it did however lead me on the right path and made it easy to work out what was left.

Thanks a heap
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question