+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Member
    Join Date
    Sep 2002
    Location
    Shirley, New York
    Posts
    260

    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.

  2. #2
    Member
    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.

  3. #3
    Banned
    Join Date
    Feb 2009
    Location
    KFNL FS2004
    Posts
    11,886
    Blog Entries
    1
    Docpad has a search and replace. DocPad Freeware download and reviews from SnapFiles

  4. #4
    Ultimate Member uethello's Avatar
    Join Date
    Oct 2001
    Location
    Charlotte, NC
    Posts
    1,780
    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.

  5. #5
    Banned
    Join Date
    Feb 2009
    Location
    KFNL FS2004
    Posts
    11,886
    Blog Entries
    1
    I didn't know notepad did that.

  6. #6
    Member
    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.

  7. #7
    Member
    Join Date
    Sep 2002
    Location
    Shirley, New York
    Posts
    260
    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

  8. #8
    Member
    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?

  9. #9
    THE Gimp Clown Fish! nemowolf's Avatar
    Join Date
    Jun 2007
    Location
    Bay Area
    Posts
    4,936
    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.

    TechIMO Folding@home Team #111 - Crunching for the cure!

  10. #10
    Junior 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

  1. DOS batch file to FTP download files by reading from the text file
    By Abhijat_TIMO in forum Applications and Operating Systems
    Replies: 0
    Last Post: September 13th, 2010, 02:02 PM
  2. Need help on formating text file
    By yogeshverma in forum Linux and Unix
    Replies: 1
    Last Post: December 3rd, 2009, 02:26 AM
  3. Want to replace batch file with a GUI
    By washe in forum Webmastering and Programming
    Replies: 3
    Last Post: December 3rd, 2005, 10:30 PM
  4. [linux] console -> text file?
    By samwichse in forum Linux and Unix
    Replies: 3
    Last Post: June 25th, 2004, 02:06 PM
  5. Auto Text file write
    By Pritesh in forum Technical Support
    Replies: 3
    Last Post: September 20th, 2003, 01:36 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews