Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Batch to scan test file and change content

Posted on 2012-04-13
4
Medium Priority
?
373 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 11

Accepted Solution

by:
paultomasi earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

877 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