Solved

Batch file to add 2 X 0's to a text file.

Posted on 2008-10-01
3
227 Views
Last Modified: 2012-05-05
I have a text file - containing data such as:

   AAJO011180A06755240105A    88.00309200810540
    AAJO011180A06755240105A    66.01009200811270
    AAJO011180A06755240105A   106.01709200810560
    AAJO011180A06755240105A    86.0240920081037L
    ACCE011180A067ADB30105A   190.00409200813570
    ACCE011180A067ADB30105A    68.0180920081342L
    AFAD011180200DF11E0105A   272.00109200810390
    AFAD011180200DF11E0105A    22.00809200810320
    AFAD011180200DF11E0105A    38.01509200810380
    AFAD011180200DF11E0105A    28.0220920081039L

I need a batch file or similar to add 2 zeros after the 4th Letter ie AAJO011180A06755240105A     will become AAJO00011180A06755240105A.

Any help will be appreciated.
test.txt
0
Comment
Question by:grahamsmyth
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 22617845

Set output=NewFile.txt

for /f "delims=" %%a in (test.txt) do call :process "%%a"

goto :eof
 

:process

set strData=%~1

set head=%strData:~0,4%

set tail=%strData:~4%

echo %strData%

echo %head%

echo %tail%

echo %head%00%tail% >> %output%

Open in new window

0
 
LVL 2

Author Closing Comment

by:grahamsmyth
ID: 31502115
Absolutely perfect - thanks very much!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22618265
Happy to help - thanx for the grade! :^)
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

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…
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

22 Experts available now in Live!

Get 1:1 Help Now