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

Find and Replace in Batch files

Original Message
Name: ashlesha
Date: May 14, 2005 at 02:19:16 Pacific
Subject: Find and Replace in Batch files
OS: WIndows XP /DOS
CPU/Ram: Pentium 4- 504MB RAM
Comment:
Hi,
I want to create a file to do the following:
1. Create multiple copies of a folder and rename them in a numerically ascending order.
2. Open a specific file from the folder and change some of the contents.
3. save the changed file.
4. repeat actions 2 and 3 for all the copies. However, the changes in their individual files will be different for each folder.

I think i can do the first step. However, i cant find a command to find and Replace the text in a file.
I can use the findstr "string" path:filename cmd to find the required string, but how do i replace it?



Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: May 14, 2005 at 04:04:10 Pacific
Subject: Find and Replace in Batch files
Reply: (edit)
No obvious way with the "tools" provided by DOS / XP.

I think you're stuck with 3rd party utils.

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 2
Name: wizard-fred
Date: May 15, 2005 at 16:40:25 Pacific
Subject: Find and Replace in Batch files
Reply: (edit)
1 - You cannot create multiple copies of a folder unless there in different folders. Your best method is to create the folders in one folder then copy the files. i.e.
md dir01
md diro2
md dir03
...
md dirnn
copy dirxx\*.* dir01
copy dirxx\*.* dir02
copy dirxx\*.* dir03
...
copy dirxx\*.* dirnn

2,3,4 To open, replace, save will require 3rd party software unless the contents is simple enough that it could be created by other means.


Report Offensive Follow Up For Removal

Response Number 3
Name: ashlesha
Date: May 16, 2005 at 00:49:21 Pacific
Subject: Find and Replace in Batch files
Reply: (edit)
Hi,

Thanks for your responses guys.

I can find text and write the changes back to the original file using the FOR command.
but is there a way to delete a particular line in the file?
m looking into 3rd party tools.


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: May 16, 2005 at 01:39:27 Pacific
Subject: Find and Replace in Batch files
Reply: (edit)
As to removing lines, assuming it's a text file, you can:

find /v "string" < file > newfile

which will put all the lines NOT containing the string into newdile.

***
The two 3rd party changers I use are:

Change9.11

Change.com

The change.com will work on files up to about 32KB. For bigger ones you need the EXE.

The EXE version has complete docs. I you decide to use the COM ver, ask for syntax help.

M2


If at first you don't succeed, you're about average.


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: Find and Replace in Batch files

Comments:

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


Data Recovery Software




Environment Variable to a text file

Restoring Problem

3 Pin Case Fan Connector???

Can't get to internet

HP/Compaq 6710b


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