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

Re: [Clip] Delete thousands of lines (long)

Expand Messages
  • Dick Gascoigne
    Chuck - ... Here s a clip that I use to do just that. I m running OE, but I don t know if that makes a difference. You d drag messages from your Inbox (or
    Message 1 of 9 , Jan 1, 2004
    View Source
    • 0 Attachment
      Chuck -
      > At 02:03 AM 12/30/03 -0000, you wrote:
      > >I'm trying to delete large attachments from my email inbox.

      Here's a clip that I use to do just that. I'm running OE, but I don't know
      if that makes a difference.

      You'd drag messages from your Inbox (or wherever) into a desktop folder,
      then run the clip.The description of what it does is in the clip. I'm sure
      someone can do it more efficiently, but it works for me :-) I'll let you
      work out the "long lines" that need to be patched back :-)

      ------- start clip ----------
      ; Written January 29, 2003 by Dick Gascoigne
      ; richardg@...
      ;
      ; Clip will remove attachments from Outlook Express .eml files, and put a
      list of the removals in the email body.
      ; To use it, drag all email files to be processed into a Windows directory
      (specified in the "SetArray"
      ; command below. Run the clip, and then drag all the files with _Strip in
      the file name back into OE.
      ; The original file is deleted, and you may then delete the original
      messages.
      ;
      ; How it works
      ; For each file, it will look first for an HTML body. If not found, then a
      plain text body.
      ; Then it will record all attachment names, and then delete them all.
      ; The list of deleted attachment names will be inserted in the body at the
      top of the message,;
      ; and the string "_stripped" added to the Subject line.
      ; The email Body and attachment names and file sizes are added to a log.
      ; The modified email is saved as a file of the same name, appended with
      _STRIP.
      ; After processing all files, the log is saved in the same directory, named
      DeleteLog.txt, and
      ; displayed in a new text window.
      ; The new emails can be dragged back into Outlook Express
      ;
      ; It is not known if email from other systems can also be handled. Probably
      so, if the system
      ; can save them as text files, and import text also.
      ;
      ; Known bug -- Some email may contain an inline forwarded message which has
      an HTML section preceeding
      ; its attachments. StripAttach puts the deleted file list in that section,
      which does not get displayed.
      ; To fix this, have the clip ALSO find the first plain/text section, and
      also put the list there.
      ;
      ^!ClearVariables
      ^!SetListDelimiter ;
      ; Change the following to your temporary .eml file holder path.
      ^!Set %FilePath%="D:\Documents\Outlook Mail\EmailHolder\"
      ; Get the list of *.eml files
      ^!SetArray %Filenames%=^$GetFiles(^%FilePath%;"*.eml";Unsorted)$
      ^!Set %NRofFiles%=^%Filenames0%
      ; make sure there are some
      ^!If ^%NRofFiles%>0 FirstFile
      ^!Info There are no .eml files to be processed in ^%FilePath%
      ^!GoTo END
      :FirstFile
      ^!Set %NR%=0
      ; start the log
      ^!Set %Log%=^%NRofFiles% E-mails processed and attachments deleted by clip
      NoteTab clip "StripAttachments"^%NL%On ^$GetDate(dd/mm/yyy hh:mm)$^%NL%
      :LOOP_THRU_FILES
      ^!Inc %NR%
      ; see if we've processd all yet
      ^!If ^%NR%>^%NrofFiles% ALL_FILES_DONE
      ; Pick up original file size, for log info
      ^!Set %InFileSize%=^$GetFileSize(^%Filenames^%NR%%)$
      ; Accumulate it
      ^!Set %InSizeAll%= ^$Calc(^%InSizeAll%+^%InFileSize%)$
      ; register this file in log
      ^!Set %Log%=^%Log%^%NL%^$StrFill("- ";25)$^%NL%File:^%Filenames^%NR%%^%NL%
      ^!Open "^%Filenames^%NR%%"
      ^!StatusShow Now checking file ^%NR% of ^%NrofFiles%
      ^!SetScreenUpdate OFF
      ^!SetWordWrap OFF
      ^!ClearVariable %NameList%
      ^!Jump TEXT_START
      ; See if there are any named attachments. If not skip this email
      ^!Find "[\s\t]name=\"" RIS
      ^!IfError NothingDeleted
      :FindDATE
      ; Find the Date: line and pick up the time to add to the saved filenam to
      make it unique
      ; (OE uses the Subject as the file name, and messages of a thread tend to
      have the same name)
      ^!ClearVariable %Time%
      ^!Jump TEXT_START
      ^!Find "Date:" RIS
      ^!IfError FindHTML
      ^!MoveCursor +1
      ^!Find ":" RIS
      ^!MoveCursor -2
      ^!SelectTo ^$GetRow$:^$Calc(^$GetCol$+5)$
      ; Get the date and time
      ^!Set %Time%=^$StrReplace(":";"";"^$GetSelection$";True;False)$
      :FindHTML
      ; Look for body text coded in HTML
      ; First, initialize
      ^!Set %IsHTML%=False
      ^!Set %IsBody%=True
      ^!ClearVariable %LogNoBody%
      ;
      ^!Jump TEXT_START
      ^!Find "text/html" RIS
      ^!IfError FindTEXT
      ; Look for a named HTML section masquerading as an HTML body
      ; If an attachment, it will be named. Check this line and the next line
      ^!If ^$StrPos(" name=";"^$GetLine$^$GetLine(+1)$";False)$>0 FindTEXT
      ^!Set %IsHTML%=True
      ^!GoTo FoundBody
      ; There's no HTML in the body, look for plain text
      :FindTEXT
      ; we're here becaused the email body has no HTML version. look for text
      version
      ^!Jump TEXT_START
      ^!Find "text/plain" IS
      ^!IfError NoBody ELSE FoundBody
      :NoBody
      ; Neither HTML nor Text sections
      ^!Set %LogNoBody%=^tNO BODY TEXT WAS FOUND BY STRIPPER^%NL%
      ^!Set %IsBody%=False
      ; Set up to delete everything after the header
      ^!Find "Content-Type" I
      ; If not found, don't know what to do. Go on to next file.
      ^!IfError NothingDeleted
      ^!Set %BodyEndRow%=^$GetRow$
      ^!Set %BodyStartRow%=^$GetRow$
      ^!GoTo Section_Name_Loop
      ; If neither Text nor HTML, assume there's no body
      ; ** For now, ignore email. Later, look at what else to do with it. **
      :FoundBody
      ; Mark the row starting the body
      ^!Find "^%NL%^%NL%" I
      ^!Set %BodyStartRow%=^$Calc(^$GetRow$+2)$
      ; Find backwards the previous Boundary name
      ; That will be used to identify section boundaries
      ^!Find "boundary=" RICB
      ^!Find "\"" RIS
      ^!Select EOL
      ; Take quotation marks off
      ^!Set %BodyBoundary%=^$StrReplace(""";"";"^$GetSelection$";No;No)$
      ^!SetClipboard ^%BodyBoundary%
      ; Look for end of body
      ^!SetCursor ^%BodyStartRow%:1
      ^!Find "^%BodyBoundary%"
      ^!IfError NothingDeleted
      ; The start of the first attachment is also the end of the body section(s)
      ^!Set %BodyEndRow%=^$GetRow$
      ; Skip files with no HTML or text/plain section (i.e. no message body)
      ; (At some point, will need to figure out how to process them)
      :Section_Name_Loop
      ; Look for an attachment section (starting with "name="
      ^!Find "[\s\t]name=\"" RIS
      ^!IfError FOUNDALLSECTIONS
      ^!Find "\"" RIS
      ^!Select EOL
      ; Take quotation marks off
      ^!Set %NameList%=^%NameList%^$StrReplace(""";"";"^$GetSelection$";No;No)$;
      ^!GoTo Section_Name_Loop
      :FOUNDALLSECTIONS
      ; Delete attachments
      ^!SetCursor ^%BodyEndRow%:1
      ^!SelectTo ^$GetLineCount$:^$GetColEnd$
      ^!Select EOL
      ^!Keyboard ALT+E D
      ; Mod Subject line to add word "<stripped>"
      ^!Jump 1
      ^!Find "Subject: " IS
      ^!IfError ModBody
      ^!Jump LINE_END
      ^!InsertText <stripped>
      :ModBody
      ; Insert NameList into email body
      ^!Set %NameList%=^%NameList%^%NL%
      ^!SetCursor ^%BodyStartRow%:1
      ; If there is no body, insert a boundary
      ^!IfTrue ^%IsBody% Insert_Deletion_Info
      ; go to end of stripped email
      ^!Jump TEXT_END
      ; create a mesage body starting boundary
      ^!InsertText boundary="zzz"^%NL%^%NL%^%NL%There was no body text^%NL%^%NL%
      :Insert_Deletion_Info
      ; Insert list of removed files, in red if email body is in HTML
      ^!IfTrue ^%IsHTML% ^!InsertText <HTML><DIV><FONT face=3DArial
      color=3D#ff0000 size=3D2>
      ^!InsertText NoteTabPro's Clip "Strip OE Attachments" has deleted
      attachments:^%NL%^%NameList%
      ^!IfFalse ^%IsHTML% ^!InsertText ^p^p
      ^!IfTrue ^%IsHTML% ^!InsertText   
      ^!IfTrue ^%IsHTML% ^!InsertText </FONT></DIV><DIV><FONT face=3DArial
      size=3D2></FONT> </DIV></HTML>
      ; Change Body line
      ; Find Body line
      ^!Jump TEXT_START
      ^!Find "\Body: " IRS
      ^!IFError UpdateLog
      ; Get the Body
      ^!Select EOL
      ^!Set %BodyLine%=^$StrUrlDecode("^$GetSelection$)$
      ^!Jump LINE_END
      ^!InsertText "<Stripped>"
      ^!GoTo UpdateLog
      :NothingDeleted
      ^!Set %Log%=^%Log%^tNothing Deleted^%NL%
      ^!Close
      ; Go get another file (no need to save, cause no attachment deleted)
      ^!Goto LOOP_THRU_FILES
      :UpdateLog
      ^!Set %Log%=^%Log%^tDeleted: ^%NameList%
      ^!Set %Log%=^%Log%Saved As:
      ^%FilePath%^$GetName(^%Filenames^%NR%%)$^%Time%_Strip.eml^%NL%
      ; Save email, with date/time and "_strip" appended to name to make it
      unique and show that attachments deleted
      ^!Save As "^%FilePath%^$GetName(^%Filenames^%NR%%)$^%Time%_Strip.eml"
      ; remove the original
      ^!DeleteFile ^%FilePath%^$GetName(^%Filenames^%NR%%)$.eml
      ; get the new file size
      ^!Set
      %OutFileSize%=^$GetFileSize(^%FilePath%^$GetName(^%Filenames^%NR%%)$^%Time%_
      Strip.eml)$
      ^!Set %OutSizeAll%= ^$Calc(^%OutSizeAll%+^%OutFileSize%)$
      ^!Set %Log%=^%Log%Saved ^%InFileSize% - ^%OutFileSize% =
      ^$Calc(^%InFileSize%-^%OutFileSize%)$^%NL%
      ^!Close
      ; Go get another
      ^!GoTo LOOP_THRU_FILES
      ;
      :ALL_FILES_DONE
      ; put the log text in a new window
      ^!Toolbar New Document
      ^!Set %Log%=^%Log%^%NL%^$StrFill("==";25)$^%NL%TOTAL SAVED: ^%InSizeAll-
      ^%OutSizeAll% = ^$Calc(^%InSizeAll-
      ^%OutSizeAll%)$^%NL%^$StrFill("==";25)$^%NL%
      ^!InsertText ^%Log%
      ; add the log text to the cumulative log record file
      ^!AppendToFile "^%FilePath%DeleteLog.txt" ^%Log%
      ^!Info All done
      --------end clip ----------
    • Chuck Anderson
      ... don t know ... Wow! I can t wait to try these out. I wonder if I can get the message back into my Inbox (or the mail folder it came from) in
      Message 2 of 9 , Jan 2, 2004
      View Source
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "Dick Gascoigne"
        <dick.gascoigne@a...> wrote:
        > Chuck -
        > > At 02:03 AM 12/30/03 -0000, you wrote:
        > > >I'm trying to delete large attachments from my email inbox.
        >
        > Here's a clip that I use to do just that. I'm running OE, but I
        don't know
        > if that makes a difference.

        Wow! I can't wait to try these out.

        I wonder if I can get the message back into my Inbox (or the mail
        folder it came from) in Mozilla-Thunderbird).

        I got your message about one at a time. Mozilla won't let me drag and
        drop, so that's not a problem. I have to save the message and can
        alter the name then. I'd only do one at a time anyway.

        Thanks,
        Chuck
      • Dick Gascoigne
        Chuck wrote - ... Sheri says that my OE uses a different email format, so I don t know if my clip will process the M-Z format correctly. If not, send me a
        Message 3 of 9 , Jan 4, 2004
        View Source
        • 0 Attachment
          Chuck wrote -
          > I wonder if I can get the message back into my Inbox (or the mail
          > folder it came from) in Mozilla-Thunderbird).

          Sheri says that my OE uses a 'different' email format, so I don't know if my
          clip will process the M-Z format correctly. If not, send me a copy of one
          with some (short) attachments -- as a zip file would be best -- and I'll see
          about fixing the clip.

          Re: getting the message back into your inbox...
          I haven't been able to do so in OE. Drag and drop is the only way I could
          find to get messages out & back in.

          If M-Z allows you to Copy an email from a folder and Paste into the Inbox,
          or to Import a file, then you should be able to do that from a clip. (OE
          does not allow the Paste of an email, but you can Drop one into the Inbox.)

          Dick Gascoigne
          Singapore

          ----- Original Message -----
          From: "Chuck Anderson" <hairtwoday@...>
          To: <ntb-clips@yahoogroups.com>
          Sent: Saturday, 03 January, 2004 9:42 AM
          Subject: Re: [Clip] Delete thousands of lines (long)


          > --- In ntb-clips@yahoogroups.com, "Dick Gascoigne"
          > <dick.gascoigne@a...> wrote:
          > > Chuck -
          > > > At 02:03 AM 12/30/03 -0000, you wrote:
          > > > >I'm trying to delete large attachments from my email inbox.
          > >
          > > Here's a clip that I use to do just that. I'm running OE, but I
          > don't know
          > > if that makes a difference.
          >
          > Wow! I can't wait to try these out.
          >
          > I wonder if I can get the message back into my Inbox (or the mail
          > folder it came from) in Mozilla-Thunderbird).
          >
          > I got your message about one at a time. Mozilla won't let me drag and
          > drop, so that's not a problem. I have to save the message and can
          > alter the name then. I'd only do one at a time anyway.
          >
          > Thanks,
          > Chuck
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          > To visit your group on the web, go to:
          > http://groups.yahoo.com/group/ntb-clips/
          >
          > To unsubscribe from this group, send an email to:
          > ntb-clips-unsubscribe@yahoogroups.com
          >
          > Your use of Yahoo! Groups is subject to:
          > http://docs.yahoo.com/info/terms/
          >
          >
          >
          >
        • hugo_paulissen
          Hi Chuck and the rest of you, A while back I suffered with a similar problem and exchanged some notes with Dick about it. When I saw your original message-file
          Message 4 of 9 , Jan 5, 2004
          View Source
          • 0 Attachment
            Hi Chuck and the rest of you,

            A while back I suffered with a similar problem and exchanged some
            notes with Dick about it. When I saw your original message-file
            (http://cycletourist.com/temp/InboxExample) I thought about a program
            that could be useful for you.

            I'm not sure if this will help you any further (I didn't exactly
            _follow_ this thread), but it could be a helpful alternative...

            I saved your text as binemail.txt and dragged it over the left pane
            of UUDWin (which I didn't use in a looong time, grab it at
            http://my.execpc.com/~mspankus/) and I could easily extract
            Esther_im_Südfrankreich-Urlaub_(6-03).jpg
            Esther_und_Bernd_im_Südfrankreich-Urlaub_(6-03).jpg
            Feuermachen im Mittel (21-11-03) 1.jpg
            Kirschenernte (16-6-03) 1.jpg

            Obviously I couldn't open the images, and I couldn't locate the
            original message in the folder I created for the extracted parts, but
            perhaps with some tweaking and/or shuffling between applications you
            could easily get the bodytext as well.

            HTH,

            Hugo
          • Chuck Anderson
            ... program ... This program is very slick, works very well, but I want it to remove the attachments from the original file, which it does not do. Still,
            Message 5 of 9 , Jan 5, 2004
            View Source
            • 0 Attachment
              --- In ntb-clips@yahoogroups.com, "hugo_paulissen" <H.Paulissen@F...>
              wrote:
              > Hi Chuck and the rest of you,
              >
              > A while back I suffered with a similar problem and exchanged some
              > notes with Dick about it. When I saw your original message-file
              > (http://cycletourist.com/temp/InboxExample) I thought about a
              program
              > that could be useful for you.
              >
              > I'm not sure if this will help you any further (I didn't exactly
              > _follow_ this thread), but it could be a helpful alternative...
              >
              > I saved your text as binemail.txt and dragged it over the left pane
              > of UUDWin (which I didn't use in a looong time, grab it at
              > http://my.execpc.com/~mspankus/) and I could easily extract
              > Esther_im_Südfrankreich-Urlaub_(6-03).jpg
              > Esther_und_Bernd_im_Südfrankreich-Urlaub_(6-03).jpg
              > Feuermachen im Mittel (21-11-03) 1.jpg
              > Kirschenernte (16-6-03) 1.jpg

              This program is very slick, works very well, but I want it to remove
              the attachments from the original file, which it does not do.

              Still, thanks for the tip.
            • Sheri
              Hi Chuck, Did you see/try this one? http://groups.yahoo.com/group/ntb-clips/messages/11439?expand=1 Regards, Sheri
              Message 6 of 9 , Jan 5, 2004
              View Source
              • 0 Attachment
                Hi Chuck,

                Did you see/try this one?

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

                Regards,
                Sheri
              • Alec Burgess
                Chuck: for a non-Notetab solution it might be worth seeing if this one can be used to do the job: BK ReplaceEm http://www.boolean.ca/replace/ It supports
                Message 7 of 9 , Jan 6, 2004
                View Source
                • 0 Attachment
                  Chuck: for a non-Notetab solution it might be worth seeing if this one can
                  be used to do the job:

                  BK ReplaceEm http://www.boolean.ca/replace/

                  It supports RegExp and some other methods.

                  Regards ... Alec
                  --

                  ---- Original Message ----
                  From: "Sheri" <silvermoonwoman@...>
                  To: <ntb-clips@yahoogroups.com>
                  Sent: Tuesday, January 06, 2004 02:45
                  Subject: [gla: Re: [Clip] Delete thousands of lines (long)

                  > Hi Chuck,
                  >
                  > Did you see/try this one?
                  >
                  > http://groups.yahoo.com/group/ntb-clips/messages/11439?expand=1
                • Chuck Anderson
                  ... Hi Sheri, I haven t tried it yet, but I will. ... My to-do list gets longer as the day gets shorter - every day. I knew this might seem rude to you (my
                  Message 8 of 9 , Jan 6, 2004
                  View Source
                  • 0 Attachment
                    --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@c...> wrote:
                    > Hi Chuck,
                    >
                    > Did you see/try this one?
                    >
                    > http://groups.yahoo.com/group/ntb-clips/messages/11439?expand=1
                    >
                    > Regards,
                    > Sheri

                    Hi Sheri,

                    I haven't tried it yet, but I will.

                    ... My to-do list gets longer as the day gets shorter - every day.

                    I knew this might seem rude to you (my delay in replying) after your
                    great efforts, but I *will* try it and all other solutions offered,
                    and I will get back to this group.

                    (I have 25 years of netiquette experience.)

                    Chuck
                  • Sheri
                    ... The ongoing discussion of a problem I thought was solved just made me think you had missed that message. Ironically, my intention was to save you some
                    Message 9 of 9 , Jan 7, 2004
                    View Source
                    • 0 Attachment
                      At 09:47 PM 1/6/2004 +0000, you wrote:
                      >--- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@c...> wrote:
                      >> Hi Chuck,
                      >>
                      >> Did you see/try this one?
                      >>
                      >> http://groups.yahoo.com/group/ntb-clips/messages/11439?expand=1
                      >>
                      >> Regards,
                      >> Sheri
                      >
                      >Hi Sheri,
                      >
                      >I haven't tried it yet, but I will.
                      >
                      >... My to-do list gets longer as the day gets shorter - every day.
                      >
                      >I knew this might seem rude to you (my delay in replying) after your
                      >great efforts, but I *will* try it and all other solutions offered,
                      >and I will get back to this group.
                      >
                      >(I have 25 years of netiquette experience.)
                      >
                      >Chuck

                      The ongoing discussion of a problem I thought was solved just made me think you had missed that message. Ironically, my intention was to save you some time.

                      Sheri
                    Your message has been successfully submitted and would be delivered to recipients shortly.