Tapatalk

Clean Up Files - all tabs to spaces, trim trailing spaces, remove consecutive blank lines

Clean Up Files - all tabs to spaces, trim trailing spaces, remove consecutive blank lines

9
NewbieNewbie
9

    Jun 09, 2011#1

    Good afternoon. I've gotten in hundreds of files that all need the following done on in this order:

    Change All Tabs to Spaces
    Trim Trailing Spaces
    Remove Consecutive Blank Lines (two or more) and change to just one

    For example - I have


    djsdkjsdjjkejf TAB TAB TAB TAB jkdjkfskjkekrkej fjksdfksdjfjkejkwjekfjksdf SPACE SPACE SPACE PARAGRAPH MARK
    ddjjfll kkellsll jjjekkkk TAB TAB dkdklwlekdkkfskdlkdjsklkd TAB TAB TAB TAB dskfdkjdjfdkkwekrekf SPACE PARAGRAPH MARK
    PARAGRAPH MARK
    PARAGRAPH MARK
    PARAGRAPH MARK
    PARAGRAPH MARK
    PARAGRAPH MARK
    dsfkdkkdskfkdekkkkkk dkdkskdfjdk TAB TAB TAB TAB jdfkskdfkdk SPACE SPACE SPACE PARAGRAPH MARK
    PARAGRAPH MARK
    dkdsdjfkdksjkfjkejkwekkdsjfjkd TAB TAB TAB djfksdjkfdks SPACE SPACE SPACE SPACE PARAGRAPH MARK


    I need:

    djsdkjsdjjkejf SPACE SPACE SPACE SPACE jkdjkfskjkekrkej fjksdfksdjfjkejkwjekfjksdfPARAGRAPH MARK
    ddjjfll kkellsll jjjekkkk SPACE SPACE dkdklwlekdkkfskdlkdjsklkd SPACE SPACE SPACE SPACE dskfdkjdjfdkkwekrekfPARAGRAPH MARK
    PARAGRAPH MARK
    dsfkdkkdskfkdekkkkkk dkdkskdfjdk SPACE SPACE SPACE SPACE jdfkskdfkdkPARAGRAPH MARK
    PARAGRAPH MARK
    dkdsdjfkdksjkfjkejkwekkdsjfjkd SPACE SPACE SPACE djfksdjkfdksPARAGRAPH MARK

    The simple It's mainly the removing consecutive blank lines that I am having the trouble with. I've read the FAQs and the in the PowerTips and researched as much as I can but all of them seem to just remove ALL blank lines (and even then states you have to keep running it over and over to do multiple lines.

    I was thinking there must be a way to use the
    find ^p$
    to be two or more and replace with ^p

    Any assistance would be appreciated.

    L

    6,685587
    Grand MasterGrand Master
    6,685587

      Jun 10, 2011#2

      Multiple blank lines (with no spaces/tabs) can be deleted for example with using the UltraEdit regular expression searching for ^p^p[^p]+ and using ^p^p as replace string. That expression is for DOS terminated lines. With Unix or Perl engine the search string is \r\n\r\n[\r\n]+ and the replace string \r\n\r\n. But those expressions do not remove all blank lines at top of the file. The macro could be:

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Top
      TrimTrailingSpaces
      TabsToSpaces
      Find RegExp "  +"
      Replace All " "
      Find RegExp "^p^p[^p]+"
      Replace All "^p^p"
      Key END
      IfColNum 1
      DeleteLine
      Key END
      IfColNum 1
      DeleteLine
      EndIf
      EndIf
      Top
      The code below second Find/Replace All is for deleting 1 or 2 blank lines at top of the file. I don't know if you need that code in your files.