1. Please take 30 seconds to register your free account to remove most ads, post topics, make friends, earn reward points at our store, and more!  

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

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


  1. jady

    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.

    Anyone????
     
  2. Georynn

    Georynn

    Dec 4, 2007
    Memphis,Tn
    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....

    http://en.wikipedia.org/wiki/Sed
     
  3. cdef

    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

    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

    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

    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.

    hth.
    --ryano
     
  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.

     
    Mar 5, 2021

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.