-
January 10th, 2012, 04:20 PM #1
Batch file to search and replace text in text file
Hi All,
I'm hoping that someone could help me out. I can only use a batch file for this at the moment.
I need to search for a line of text in a text file and remove it or REM it out. Looking to do this with a batch file.
So say I have a line called ABC123 in text file called test1. I either need to delete that line or REM it out. That line can be in various spots within the same file, depending on when a software was installed.
Any idea on how to do this?
Thanks in advance.
-
January 10th, 2012, 05:43 PM #2Member
- Join Date
- May 2006
- Location
- Alabama
- Posts
- 451
Any reason why you are limited to a batch file?
and I'll add, since you can run any number of different commands in that batch file, what type of system are you running, a server or desktop, what OS?Last edited by de_day; January 10th, 2012 at 05:45 PM.
-
January 10th, 2012, 08:57 PM #3
Docpad has a search and replace. DocPad Freeware download and reviews from SnapFiles
-
January 10th, 2012, 09:44 PM #4
Open Windows Notepad
Load test1.txt
Click "Edit"
Click "Replace"
type ABC123 in the "Find what" field
type what you want to replace it with in the "Replace with" field
Make sure your cursor is at the TOP of the text file, Notepad is a simple animal.
Click "Replace All" or to be really sure click "Find Next" one at a time until you're sure it's doing what you want it to do.
-
January 11th, 2012, 02:30 AM #5
I didn't know notepad did that.
-
January 11th, 2012, 09:53 AM #6Member
- Join Date
- May 2006
- Location
- Alabama
- Posts
- 451
I was under the impression that the OP wanted to do this without opening the file in an editor. Maybe not.
-
January 11th, 2012, 12:23 PM #7
Hi all,
I'm using the batch file to backup and restore data for users. Using a VBS script apparently on our network requires special access for some users. The batch file does not prompt a user for any credentials.
Looking to automate this. Its being used on desktops/laptops running Windows XP SP3.
Thank you
-
January 11th, 2012, 03:27 PM #8Member
- Join Date
- May 2006
- Location
- Alabama
- Posts
- 451
So during a back up scenario, what would you need to find and replace and would it be for every file you backed up or only certain ones?
-
January 11th, 2012, 07:40 PM #9
if your using this in a windows environment, why are you not using powershell !?!?!
VBS is so 2007. You can run a powershell script to do that accross a domain dynamically and have it spit out a report of what machines and files were effected. Efficiency is using the right tool for a job my friend!
download powergui, find the script signing add-in, have your administrator issue you a cert for signed scripts and viola. you have a script any admin can run that has been signed to run on your domain by your domain.
PS: Batch files really!? Your batch file will run with your permissions or what ever permissions of the account logged in. Your going to have to write a VERY complicated script to run accross the network or worse run it on each individual machine. Leave batch files to login scripts my friend.
-
February 28th, 2012, 09:12 PM #10Junior Member
- Join Date
- Feb 2012
- Posts
- 9
notepad++ will do it for a all files in a folder/subfolders if you need a more advanced search and replace than normal notepad, it is free too
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
DOS batch file to FTP download files by reading from the text file
By Abhijat_TIMO in forum Applications and Operating SystemsReplies: 0Last Post: September 13th, 2010, 02:02 PM -
Need help on formating text file
By yogeshverma in forum Linux and UnixReplies: 1Last Post: December 3rd, 2009, 02:26 AM -
Want to replace batch file with a GUI
By washe in forum Webmastering and ProgrammingReplies: 3Last Post: December 3rd, 2005, 10:30 PM -
[linux] console -> text file?
By samwichse in forum Linux and UnixReplies: 3Last Post: June 25th, 2004, 02:06 PM -
Auto Text file write
By Pritesh in forum Technical SupportReplies: 3Last Post: September 20th, 2003, 01:36 PM



LinkBack URL
About LinkBacks




Reply With Quote



Hello friends..!!! You have to watch all following shows and movies at weekend time. One Life To Live Episode 18 Nikita Season 3 Episode 22 Watch Frances Ha Online Watch The Last Stand Online...
Free online movies