Loading ...
Sorry, an error occurred while loading the content.

Re: Delete thousands of lines

Expand Messages
  • Chuck Anderson
    ... Same to you, as well. May this be a fortuitous and joyful year. ... You got it. (I am a web designer - very good with Php right now - C++ in my past -
    Message 1 of 6 , Jan 1, 2004
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@c...> wrote:
      > Hi Chuck, Larry, others,
      >
      > Happy New Year!!

      Same to you, as well. May this be a fortuitous and joyful year.

      > Chuck, I think you/we need to study your file a bit more. ......

      You got it. (I am a web designer - very good with Php right now - C++
      in my past - the wayback machine.)

      Download these two short text files:

      http://cycletourist.com/temp/InboxExampleReadme.txt
      http://cycletourist.com/temp/InboxExample

      Readme explains it all - hopefully. :-)

      > I use Eudora; it decodes, saves and strips attachments from messages
      before I even see them.

      (Maybe I should switch.) ô¿Ô¬

      > Chuck, you should try my Clipcode Syntax clip package.

      I downloaded it and will install it. (After a bike ride - it's >
      50º here today!)

      Thanks again,
      Chuck
    • Sheri
      Hi Chuck, Here s another attempt. It only works on the current email message. The next email message is identified by locating the first line after the cursor
      Message 2 of 6 , Jan 2, 2004
      • 0 Attachment
        Hi Chuck,

        Here's another attempt.

        It only works on the current email message. The next email message is identified by locating the first line after the cursor that starts with the word "From".

        It deletes all attachment sections following the starting cursor position until it reaches an attachment section that has no tabfilename= line within its first few lines. It preserves the prefix text (assumed to be email text) and suffix text (everything following the first section with no attachment file name). From your example it appears that the message ends with one of those boundary lines. That last boundary line is treated as part of the suffix text and is not removed. I thought perhaps it could cause problems with your email program if it was missing.

        Its very fast. I altered your test file to put over 15000 lines in each attachment. I discovered that most of the typical manners of deleting or pasting or inserting over these large blocks worked very slowly when done with clip instructions. I don't know why these were so slow since (for example) doing similar tasks manually were not delayed. Fortunately I discovered that using ^!InsertSelect ^$GetFileText(filename.txt)$ to replace thousands of selected lines didn't have this problem. Otherwise, I would be suggesting a Perl solution (were you aware that NoteTab clips can run Perl?)

        It doesn't really work as you said you wanted it to. You're not prompted for a search string.

        Instead, you should save any attachments in the current message that you want to keep. Then position the cursor within the text message (i.e., below its "------=_NextPart_" line) and run the clip. The line count and file name associated with each deleted section is preserved.

        If this works well, you could make a new clip with a clip wizard that helps you locate proper starting points and then automatically runs this clip with a ^!Clip command.

        To copy this clip without broken lines, copy/paste from somewhere around this page:

        http://groups.yahoo.com/group/ntb-clips/messages/11439?expand=1

        Regards,
        Sheri

        H="Delete attachments"
        ^!SetWordWrap Off
        ^!Continue Cursor position should be in or below email text (above attachments). If necessary Cancel and reposition the cursor.
        ^!SetHintInfo Working ...
        ^!SetScreenUpdate Off
        ^!DeleteFile "^$GetLibraryPath$delatt.txt"
        ^!Set %curdoc%=^$GetDocIndex$
        ^!Set %beginpos%=^$GetRow$:^$GetCol$
        ;Operate only within this message - next starts with "From" in col 1
        ;Or if no next message, operate to end of file
        ^!Find "^From" RS
        ^!IfError Next Else Skip_1
        ^!Jump Doc_End
        ^!Jump -1
        ^!SelectTo ^%beginpos%
        ;Copy from starting point to end of message to temporary buffer
        ^!ClipBoardSave
        ^!SetClipboard ^$GetSelection$
        ^!Menu Edit/Paste New
        ^!SetClipboard ""
        ^!Select All
        ^!SetArray %attachnames%=
        ^!Set %Index%=0
        ^!Jump Doc_Start
        :Loop
        ^!Inc %Index%
        ^!Find "------=_NextPart_" TIS
        ^!IfError Out
        ^!Set %startpos%="^$GetRow$:1"
        ;Don't delete from 1st section of message (s/b text)
        ^!If ^%Index%=1 Next Else Skip_3
        ^!SelectTo 1:1
        ^!AppendToFile "^$GetLibraryPath$delatt.txt" ^$GetSelection$
        ^!SetCursor ^%startpos%
        ^!Find "^P^P" IS
        ^!SelectTo ^%startpos%
        ;Parse filename
        ^!Find "^P^Tfilename="" THS
        ;If attachment has no filename, preserve all remaining attachments in file
        ^!IfError Last
        ^!Jump Select_End
        ;Parse filename
        ^!Find "[^"]*" RS
        ^!Set %attachnames^%Index%%="^$GetSelection$"
        ^!SetCursor ^%startpos%
        ^!Jump +1
        ^!Find "------=_NextPart_" IS
        ^!IfError Last
        ^!Jump Select_Start
        ^!SelectTo ^%startpos%
        ^!Set %count%=^$StrCount("^%NL%";"^$GetSelection$";No;No)$
        ^!AppendToFile "^$GetLibraryPath$delatt.txt" *** "^%attachnames^%Index%%"(^%count% LINES DELETED)^%NL%
        ^!Jump Select_End
        ^!Goto Loop
        :Last
        ;leave last boundary in place
        ^!If ^%Index%=1 Error
        ^!Jump Doc_End
        ^!SelectTo ^%startpos%
        ^!AppendToFile "^$GetLibraryPath$delatt.txt" ^%NL%^$GetSelection$
        :Out
        ^!Close Discard
        ^!SetDocIndex ^%curdoc%
        ^!IfFileExist "^$GetLibraryPath$delatt.txt" Next Else Error
        ^!InsertSelect ^$GetFileText("^$GetLibraryPath$delatt.txt")$
        ^!SetView ^$GetRowStart$:1
        ^!Goto ClearVars
        :Error
        ^!Close Discard
        ^!SetDocIndex ^%curdoc%
        ^!SetCursor ^%beginpos%
        ^!Info Error - Cursor was not within message text or 1st boundary had no filename in expected format.
        :ClearVars
        ^!Clearvariable %attachnames%
        ^!Clearvariable %count%
        ^!Clearvariable %index%
        ^!Clearvariable %startpos%
        ^!Clearvariable %beginpos%
        ^!Clearvariable %curdoc%
        ^!ClipBoardRestore
        ;end
      Your message has been successfully submitted and would be delivered to recipients shortly.