Anyone here know how to write batch files (.bat)?

Discussion in 'Off Topic [BG]' started by jady, Jul 18, 2008.

  1. jady


    Jul 21, 2006
    Modesto, CA
    I need a batch file that will take all of the txt files in a directory and replace all of the "SEQ" and "ESQ" entries with ";" and place a carriage return after the "END" statement.

  2. Georynn


    Dec 4, 2007
    Suggestion (but time consuming)

    find <text string with quotes and no brackets> *.* > results.txt

    That will put your results into a text file named results.
    Open it in notepad, use replace command for each instance?

    There are third party tools that do this; I'm not sure you can batch that out, without an external program...

    try SED from the unix library....
  3. cdef


    Jul 18, 2003
    Do you mean a legacy DOS batch file? Well, it could be done, even if it's a little fiddly. Why not just use a text editor that has the command 'Find/Replace In Files'?.
  4. jady


    Jul 21, 2006
    Modesto, CA
    Win XP

    I am using a batch replace program right now but I was hoping to automate it to a click instead of manually typing everything into the program.

    I have to fix the code in hundreds upon hundreds of programs a day.......
  5. cdef


    Jul 18, 2003
    I'd suggest EmEditor. You can easily define very powerful macros to batch search & replace whatever text at one click. Plus, it has syntax highlighting for many programming languages. Free in this version (6.00.4). The latest shareware version is here.
  6. With WinXP out of the box I have no idea. If you are willing to either install the Cygwin package of Unix utilities or Perl the problem is trivial.
  7. ryano


    Aug 20, 2007
    Boston Area

    Hey Jady,

    As others have mentioned installing cygwin or some other Unix like tool set (that contains the sed utility) would be good. Perl is also great for this type of thing. Personally this is something I would do with Ant (with Ant contrib). A really nice build tool/utility.

    If you must use batch files I think you can use edlin to perform the search/replace. edlin is an old line editor included with DOS and it seems to still exist in Windows. I have it here on Vista so I assume it is included with previous Windows versions as well. edlin has an R option for replace.

    If you search google for "dos batch edlin search replace", you'll get some useful info.

  8. Primary

    Primary TB Assistant

    Here are some related products that TB members are talking about. Clicking on a product will take you to TB’s partner, Primary, where you can find links to TB discussions about these products.

    May 19, 2022

Share This Page