Computing.Net > Forums > Disk Operating System > Find and Replace with a BAT file?!!!!

Find and Replace with a BAT file?!!!!

Reply to Message Icon

Original Message
Name: Jaylo
Date: June 24, 2000 at 18:51:08 Pacific
Subject: Find and Replace with a BAT file?!!!!
Comment:

Hi-
I have two files, called page1.txt and page2.txt, and I need to create a bat file which will replace the text "Heading", "Heading2" , "Heading3" , and "Heading4" with whatever the user inputs. Please help. Thanks in advance!
Jaylo


Report Offensive Message For Removal


Response Number 1
Name: DoOMsdAY
Date: June 25, 2000 at 15:40:05 Pacific
Reply: (edit)

You might be able to do that with variables and %variablename%.xxx type of "coding". Can you describe the problem with a bit more detail?


Report Offensive Follow Up For Removal

Response Number 2
Name: World Library
Date: June 25, 2000 at 18:52:45 Pacific
Reply: (edit)

Hi,
Below is a file for adding to the beginning of a file or adding to the end of a file.
In dos it will allow you to start (it then exits) but alows you to type in the command with the help file visable.

If you want to run from windows then you need to call it....well you will see.

ad thefile.name b enter or ad thefile.name e


cls
@echo off
if not "%1"=="" goto 1stpr
:start
echo.
echo EXAMPLE:Type... AD MY.doc b
echo Type... AD My.doc e
echo Command Results
echo.
echo AD (file name) b Adds to the beginning of a (file).
echo AD (file name) e Adds to the end of a (file).
goto end
:1stpr
if "%2"=="" goto start
if %2==b goto 2cdpr
if %2==e goto 2cdpr
goto start
:2cdpr
if exist %1 goto ok
echo.

echo I can't seem to find a file named... %1.
echo.
echo Lets try it again, with a different spelling.
echo.
goto start
:ok
echo.
echo Type the line or lines to be added.
echo After the last line, press (F6) and (enter).
echo.
if %2==b copy con+%1 ad.$$$ > nul
if %2==e copy %1+con ad.$$$ > nul
erase %1
rename ad.$$$ %1
echo.
echo These are the new contents of $1:
echo.
more < %1
:end


The above should work so just do a copy and paste....save as ad.bat. Adjustments...knocking on wood should be easy.

Hope this is of some help.

World Library


Report Offensive Follow Up For Removal

Response Number 3
Name: DoOMsdAY
Date: June 26, 2000 at 07:03:19 Pacific
Reply: (edit)

Cool program, World Library. I'd never thought of using copy con like that. :)


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 with a BAT file?!!!!

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge