DJA wrote:
> DJA wrote:
>> I think I accidentally deleted all the email in one Thunderbird
>> account's Inbox folder. And of course, because I didn't know I'd done
>> it, I also emptied the Trash folder. I'd like to get that mail back.
>>
>> I have backed up both the Inbox, Inbox.msf, Trash, and Trash.msf
>> folders. Given their size, I can see that they probably still contain
>> the recently deleted email. I can also read the contents of both the
>> Inbox and Trash folders.
>>
>> I've done the "Change the X-Mozilla-Status: value to 0000 thing" but
>> that does not seem to have any effect. I suspect that there is some
>> combination of mechanisms in MTB (Thunderbird) whereby not only is
>> mail in the original folder (Inbox) marked as deleted, but it's also
>> marked as deleted in the Trash folder. Maybe even somewhere else as well.
>>
>> It looks like I have a few options:
>>
>> 1) find out how to make MTB see the mail normally (i.e. undelete it),
>>
>> 2) copy each email from the mbox file to a compose window and resend it
>> to myself,
>>
>> 3) figure out how to import the mbox file's contents back into MTB,
>> maybe using something like Mutt as an intermediary?,
>>
>> 4) ???.
>>
>> Any suggestions on how any of those methods might be accomplished or
>> better alternatives to those will be greatly appreciated.
>
> It looks like the solution is Option (1) above, in two parts:
>
> Part One
>
> I found no luck in mucking with the mbox files in their owning
> directories. So I figured they needed to be in as close to a virgin
> environment as possible. Creating a new subfolder in the existing
> account's tree doesn't work. User-created subfolders do not seem to get
> their own folders or files, so there is nowhere to copy the problem mbox
> files.
>
> Instead, I created a dummy email account (Inbox_maintenance), with a
> dummy user (dummy@<IN_address>. This created an empty directory
> structure for that account. Next I shut down Thunderbird.
>
> I then copied the problem Inbox, Inbox.msf, Trash, and Trash.msf files
> to the Inbox_maintenance account (overwriting the existing files).
>
> Edit the transplanted files, changing the X-Mozilla-Status: nnnn values
> to reset the 8 bit, and only the 8 bit on the LSB of the nnnn part of
> the string. That is, if nnnn = 001b, then change it to 0013; change 0008
> to 0000, etc.
>
> Restart Thunderbird.
>
> This caused the deleted email to become undeleted again. This works for
> both the Inbox and Trash mbox files. I suppose that one need not
> transplant the .msf files as MTB will just rebuild those on start anyway.
>
> Part Two
>
> There's no way I want to manually and individually do the above
> procedure for the 5-10 thousand emails in just the Inbox file alone, let
> alone that plus the 3+ MB in the Trash folder. So I need to automate the
> above procedure. I'm neither a scripting nor a Perl (or whatever)
> expert, so I'd appreciate any recipes for scripting/programming the
> change to the X-Mozilla-Status variable as shown above.
>
> Here is a list I found showing the possible values of X-Mozilla-Status:
>
> my $MSG_FLAG_READ = 0x0001;
> my $MSG_FLAG_REPLIED = 0x0002;
> my $MSG_FLAG_MARKED = 0x0004;
> my $MSG_FLAG_EXPUNGED = 0x0008;
> my $MSG_FLAG_HAS_RE = 0x0010;
> my $MSG_FLAG_ELIDED = 0x0020;
> my $MSG_FLAG_OFFLINE = 0x0080;
> my $MSG_FLAG_WATCHED = 0x0100;
> my $MSG_FLAG_SENDER_AUTHED = 0x0200;
> my $MSG_FLAG_PARTIAL = 0x0400;
> my $MSG_FLAG_QUEUED = 0x0800;
> my $MSG_FLAG_FORWARDED = 0x1000;
> my $MSG_FLAG_PRIORITIES = 0xE000;
>
>
Well, here's a one-liner to try:
-----------------------------------------------------------------------
perl -lpe '$_=sprintf("X-Mozilla-Status: %.4x", 0xFFF7 & hex("$1")) if
/^X-Mozilla-Status: ([0-9a-f]{4})$/' Inbox >I2
-----------------------------------------------------------------------
Explanation:
perl -lpe '...' Inbox > I2 reads and prints lines from Inbox to I2
lines matching the pattern /.../ are _modified_ by
replacing the trailing hex with the value anded with 0xFFF7
(4 chars are interpreted as hex, anded, then printed as hex)
(0xFFF7 being ~ 0x0008, of course)
other lines are printed unchanged
newlines are stripped on read, added on write
Hope I understood the challenge, correctly.
Regards,
..jim
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list