Solved

Searching for and Changing a record in a file

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now