Solved

Searching for and Changing a record in a file

Posted on 2008-10-30
2
155 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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