Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Find and replace a string in a file
Name: vicky29 Date: May 13, 2009 at 02:15:20 Pacific OS: Windows XP Subcategory: Batch
Comment:
Hi, I have a file which contains the name of various SQL scripts, like... T1.sql; t2.sql; t3.sql;
inside these sql scripts i have a commit statement at the end of file like.. commit;
After this commit i want to add a exit statement so it will look like.. commit; exit;
How can i do it through a batch file... Please help.
Name: Valerie (by Garibaldi) Date: May 13, 2009 at 03:00:50 Pacific
Reply:
What does it mean?
I have a file which contains the name of various SQL scripts, like... T1.sql;
inside these sql scripts i have a commit statement
Do you mean that the file contains nothing but the names of the SQL scripts or do you mean that you have a directory containing SQL scripts?
Your subject is "Find and replace a string in a file". Find what string and replace it with what?
0
Response Number 2
Name: vicky29 Date: May 13, 2009 at 04:16:30 Pacific
Reply:
no, this is a normal file like a text file, it contains the names of different sql scripts. Inside those scripts at the end of the script a "commit" is there and i have to append a exit after the commit..
commit; exit;
0
Response Number 3
Name: Valerie (by Garibaldi) Date: May 13, 2009 at 04:48:51 Pacific
Reply:
Try this. Replace filename1.txt with the name of the file containing the sql filenames only. path is the path to where the actual sql files are located.
:: Code begins...
@echo off
cls
setlocal enabledelayedexpansion
for /f %%1 in (filename1.txt) do (
set filename=%%1
echo exit;>>path\!filename!
)
:: Code ends...
Good luck.
V.
0
Response Number 4
Name: Mechanix2Go Date: May 13, 2009 at 04:57:42 Pacific
Reply:
for /f "tokens=* delims= " %%a in (myfile) do ( echo exit, >> %%a )
===================================== If at first you don't succeed, you're about average.
Summary: Need to find and replace string in a file using Batch program. It is a text file (but with a different extension simple text and there are blanks in the file). I am a Mainframe programmer and new to B...
Summary: Hi, Can someone help. I need a way to search through many text files to find an "Ã" and replace it with a "~". Or at least search through many text files and alert me if an à exists. Thanks in advan...
Summary: find and replace "ultra" with extra in files and forders names ============================ hi i want a batch file that search for all files and forlders for find and replace "ultra" to "extra"...