Solved

Batch to scan test file and change content

Posted on 2012-04-13
4
336 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
This is about my first experience with programming Arduino.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

810 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