Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Searching for and Changing a record in a file

Posted on 2008-10-30
Medium Priority
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


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


Any help would be appreciated.
Question by:mateinone
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
LVL 67

Accepted Solution

sirbounty earned 1000 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


Author Closing Comment

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

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 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