Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Replacing different text in many files "Find and Replace"  (Read 10662 times)

0 Members and 1 Guest are viewing this topic.

ALAN_BR



    Hopeful

    Thanked: 5
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Replacing different text in many files "Find and Replace"
    « Reply #15 on: November 04, 2008, 11:53:49 AM »
    Hi

    Every ( needs to be followed by )
    You may have better luck after appending
    Code: [Select]
      )
    )

    Regards
    Alan

    Soli004

      Topic Starter


      Rookie

      Re: Replacing different text in many files "Find and Replace"
      « Reply #16 on: November 04, 2008, 12:09:42 PM »
      Hello,

      ALAN_BR wrote:
      Every ( needs to be followed by )
      You may have better luck after appending
      Code:
        )
      )

      Yes sorry they are all there, the end lines, I did not wanted to write all the code as it is all there in previous answers
      Thanks Alan
      Regards



      Soli004

        Topic Starter


        Rookie

        Re: Replacing different text in many files "Find and Replace"
        « Reply #17 on: November 04, 2008, 12:55:25 PM »
        This puzzles me...

        I did remove the directory lines and only used *.mif and moved the batch to the folders with the files (under documents and settings) tried again and it could not find the files!!

        I then move the folder out of documents and setttings to under C: and then it works!!

        What causes this?

        I would refer to have it under documents and settings if that is possible

        Regards

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: Replacing different text in many files "Find and Replace"
        « Reply #18 on: November 04, 2008, 01:43:12 PM »
        Quote
        There is up to 100 unique files (file1,file2,file3,file4,file5 etc) and each of them has only one of the lines that needs to be changed, but this line can occur several hundreds times in each file.

        What happened to the d:\data directory? When the run environment is changed, the batch file must change accordingly. I probably should have made the code more bulletproof.

        Code: [Select]
        @echo off
        setlocal enabledelayedexpansion
        for /f "tokens=* delims=" %%x in ('dir /a:-d /s /b "c:\documents and settings\soli004\data\*.mif"') do (
           for /f "tokens=* delims=" %%i in ("%%x") do (
              set input=%%i
              .
              .
              .
              echo !input! >> "%%x.chg"
           )
        )

         8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein