Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Batch procedure for adding in *.txt

Original Message
Name: Tsunami
Date: February 12, 2008 at 04:24:44 Pacific
Subject: Batch procedure for adding in *.txt
OS: Windows XP Pro SP2
CPU/Ram: AMD5000 black edition
Model/Manufacturer: Asus
Comment:
I need a batch file which will find string A and then skip for example 10 places and insert string B in a txt file. There are more than one A strings


Report Offensive Message For Removal


Response Number 1
Name: tonysathre
Date: February 12, 2008 at 15:40:31 Pacific
Subject: Batch procedure for adding in *.txt
Reply: (edit)
Vertically or horizontally?

Report Offensive Follow Up For Removal

Response Number 2
Name: Tsunami
Date: February 12, 2008 at 23:44:56 Pacific
Subject: Batch procedure for adding in *.txt
Reply: (edit)
horizontally :)

Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: February 13, 2008 at 01:31:42 Pacific
Subject: Batch procedure for adding in *.txt
Reply: (edit)
:: find string A and insert string B x rows later

@echo off > newfile
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (myfile) do (
if %%a==A set /a N=0
set /a N+=1
echo %%a >> newfile
if !N!==10 echo B >> newfile
)


<font color


Report Offensive Follow Up For Removal

Response Number 4
Name: Tsunami
Date: February 13, 2008 at 03:00:43 Pacific
Subject: Batch procedure for adding in *.txt
Reply: (edit)
M2 something is missing...I get new file but its blank... ?? and there is no change in the original

thx mate


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: February 13, 2008 at 06:20:48 Pacific
Subject: Batch procedure for adding in *.txt
Reply: (edit)
Do you HVE myfile?

<font color


Report Offensive Follow Up For Removal


Response Number 6
Name: Tsunami
Date: February 13, 2008 at 06:38:51 Pacific
Subject: Batch procedure for adding in *.txt
Reply: (edit)
Here is the situation :

folder named test
inside txt file named R026.txt
in couple of lines in that txt I have a word "PIB"
I need to make change to that R026.txt so that after I get "PIB R026" with 20spaces between

Already have a batch that asks for the txt name and puts the value in %UserIn% so that I use your batch as
" @echo off > NEW.txt
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (%UserIn%.txt) do (
if %%a==PIB set /a N=0
set /a N+=1
echo %%a >> NEW.txt
if !N!==10 echo %UserIn% >> NEW.txt
) " but after that I get NEW.txt which is blank...


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch procedure for adding in *.txt

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Slow boot time

Trasnferring Documents from old HD

My k8T Neo-v usb's aren't working!

Date Modified = Date Created Time

system files on removable harddrive


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC