Solved

Batch to scan test file and change content

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This is an explanation of a simple data model to help parse a JSON feed
The viewer will learn how to dynamically set the form action using jQuery.
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 …

746 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

13 Experts available now in Live!

Get 1:1 Help Now