Using FindInFiles to "head" files

Using FindInFiles to "head" files

4
NewbieNewbie
4

    Jun 06, 2006#1

    I was trying to use "Find In Files" combined with Perl Regex to extract the first N lines from a group of files, and have the results in an output window.

    I can use wildcards to grab a group of arbitrary lines just fine, but if I grab, for instance, 7 lines, and there are 70 lines in the file, I'll get 10 items found. But I only want to see the first one.

    Is there any way to anchor a regex at the top of the file?
    Or tell the routine to stop after the first expression is found in each file?
    Or any other way to do this in UE?

    6,683583
    Grand MasterGrand Master
    6,683583

      Jun 18, 2006#2

      No, this cannot be done with a regex search.

      You can use the following macro. It collects the first 7 lines of all opened files with a name (not new files) and paste it with the full file name to a new file. The opened files are saved before the macro really starts because they must be all modified temporarily by the macro and are closed without saving.

      InsertMode
      ColumnModeOff
      HexOff
      SaveAll
      Clipboard 9
      ClearClipboard
      Loop
      Clipboard 8
      IfNameIs ""
      ExitLoop
      EndIf
      CopyFilePath
      Top
      "

      File: "
      Paste
      "

      "
      Key DOWN ARROW
      Key DOWN ARROW
      Key DOWN ARROW
      Key DOWN ARROW
      Key DOWN ARROW
      Key DOWN ARROW
      Key DOWN ARROW
      SelectToTop
      Clipboard 9
      CopyAppend
      CloseFile NoSave
      EndLoop
      ClearClipboard
      NewFile
      Clipboard 9
      Paste
      ClearClipboard
      Clipboard 0
      Top
      Key DEL
      Key DEL
      Best regards from an UC/UE/UES for Windows user from Austria

      4
      NewbieNewbie
      4

        Jun 21, 2006#3

        Thanks, Mofi. I'll give it a try and see how it does. I appreciate the help!