Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Searching for and Changing a record in a file

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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