Tapatalk

Find in Files - Match if String Not Found problem

Find in Files - Match if String Not Found problem

2

    Aug 01, 2007#1

    New to the software so bear with. I have a project where I am parsing a large number of .ini files. If these files DO NOT contain specific text I want to insert a block of text - i.e. if the file does not contain a section called [Print Default].

    I have figured out how to find the files that do not contain the text using the "Match files if string is not found" operator. I can also run a text replacement easily enough.

    The trouble is that I can't figure out a clean way to open/pass the files that DO NOT contain this text to the replacement operation so that they can be the target of my replacement. I can output the files out find to the editor window but is there a way to tell it to Open the files that are found?

    Help! This will save me an awful lot of time if I can figure it out.

    Thanks in advance!

    Casey Robertson

    Version 13.10a+1 UltraEdit Style Regular expressions

    6,685587
    Grand MasterGrand Master
    6,685587

      Aug 01, 2007#2

      Run your Find In Files with option Results to Edit Window checked.

      Assuming you have not changed the options for the Find In Files output format following macro can then be executed on this output to open all the files.

      Macro to open all files not containing a string:

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Top
      Find MatchCase "Search complete,"
      IfFound
      DeleteLine
      UnicodeToASCII
      Top
      Find "----------------------------------------^p"
      Replace All ""
      Find MatchCase RegExp "Search for files that do not contain *^p"
      Replace All ""
      Loop
      IfEof
      ExitLoop
      EndIf
      StartSelect
      Key END
      Open "^s"
      NextWindow
      DeleteLine
      EndLoop
      CloseFile NoSave
      EndIf

      The macro property Continue if a Find with Replace not found must be checked for this macro.

      Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.

      Now you can run your replace on all open files.
      Best regards from an UC/UE/UES for Windows user from Austria

      2

        Aug 01, 2007#3

        That worked perfectly! You have no idea how much time you saved me from having to figure that out. Thanks again!

        BTW, I was in Austria a couple of years ago - what a beautiful country!

        --Casey