Solved

Batch to scan test file and change content

Posted on 2012-04-13
4
327 Views
Last Modified: 2012-04-17
I need a batch file to scan the attached file for the E01, E11 and E18 characters and replace them all with S11.  Open the attached and you will see what I mean. I then either need the batch to resave the file as the original filename, or have it save a new file with the output.  I need everything in the file carried over to the new file with the changes made above.
120415.txt
0
Comment
Question by:murryc
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37841520
0
 
LVL 11

Accepted Solution

by:
paultomasi earned 500 total points
ID: 37844965
Please give this a whirl.

Run the batch file passing the file as a parameter like this:

    BATCH 120415.txt

Where 'BATCH' is the name of your batch file and '120415.txt' is the name of your text file.
@echo off
setlocal enabledelayedexpansion

(for /f "tokens=* usebackq" %%a in ("%~1") do (
  set Line=%%a
  set Line=!Line:,E01,=,S11,!
  set Line=!Line:,E11,=,S11,!
  set Line=!Line:,E18,=,S11,!
  echo !Line!
))>"%~1.tmp"

move /y "%~1.tmp" "%~1"

Open in new window

0
 

Author Comment

by:murryc
ID: 37853636
I love it!  It works like a charm.
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37855601
Thanks for choosing my excellent batch file as your solution...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

15 Experts available now in Live!

Get 1:1 Help Now