Re: script to move messages according to tags

2019-12-11 Thread Carl Worth
Yes,

Notmuch considers any email files with the same message-id header as
being the same message so won't show you multiple versions of the same
email, (unless you're specifically asking for it to with something like
--output=files).

In normal usage I never worry about the duplicates I get from mailing
lists, etc.

I hope you'll find notmuch very useful.

Have fun!

-Carl

On Wed, Dec 11 2019, Alan Schmitt wrote:
> On 2019-12-11 16:33, David Edmondson  writes:
>
>> How you decide to deal with multiple results is really up to you 
>> - in my
>> case I move/delete all of them (except that I don't actually 
>> delete
>> anything).
>
> This is probably the key: I'm used to file-based MUA that will 
> show me
> duplicates. If notmuch hides them from me, I could just ignore 
> that they
> exist (it's not like it's taking too much space anyway…)
>
> Best,
>
> Alan
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: script to move messages according to tags

2019-12-11 Thread Alan Schmitt

On 2019-12-11 16:33, David Edmondson  writes:

How you decide to deal with multiple results is really up to you 
- in my
case I move/delete all of them (except that I don't actually 
delete

anything).


This is probably the key: I'm used to file-based MUA that will 
show me
duplicates. If notmuch hides them from me, I could just ignore 
that they

exist (it's not like it's taking too much space anyway…)

Best,

Alan


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: script to move messages according to tags

2019-12-11 Thread David Edmondson
On Wednesday, 2019-12-11 at 16:28:20 +01, Alan Schmitt wrote:

> I do have one small question: how do you deal with mails that have
> duplicates? For instance, when I send a mail to a mailing list, I end
> up with both the sent email and the one I later receive from the
> list. If I tag the send one with deleted (no need to keep it), won't I
> run the risk to delete both mails?

If you have the id of a message you can get a list of all of the
corresponding files with:
  notmuch search --exclude=false --output=files $id

How you decide to deal with multiple results is really up to you - in my
case I move/delete all of them (except that I don't actually delete
anything).

dme.
-- 
Our President's crazy, did you hear what he said?
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: script to move messages according to tags

2019-12-11 Thread Alan Schmitt

Hello Örjan,

On 2019-12-11 13:58, Örjan Ekeberg  writes:

Below is the script that I use which does more-or-less what you 
are

asking for.


Thank you very much, this is most helpful.

I do have one small question: how do you deal with mails that have
duplicates? For instance, when I send a mail to a mailing list, I 
end up
with both the sent email and the one I later receive from the 
list. If I
tag the send one with deleted (no need to keep it), won't I run 
the risk

to delete both mails?

(Maybe I'm dealing with sent mails in a wrong way… I don't know 
what

notmuch best practice is in that case.)

Thanks,

Alan


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: script to move messages according to tags

2019-12-11 Thread Örjan Ekeberg
Alan Schmitt  writes:
> Has someone written such a script that I could copy and 
> adapt?
>
> My use cases are:
> - find files with a deleted flag not in the Trash and move them to 
>   the
> Trash
> - find files with an archive flag in my active mail store and move 
>   them
> to my local mail store

Hi Alan,

Below is the script that I use which does more-or-less what you are
asking for.

The only "magic" here is the function safeMove which strips the
identifier number and flags from the filename when a file is moved.
These identifier numbers are added by mbsync which is the program I use
to synchronise my folders with our webmail server, and keeping the
numbers when moving the files proved to interfere with its
synchronisation logic.

Cheers,
Örjan

=== 8< ===
#!/bin/bash

MAILDIR=$HOME/MyMail

# Move a message file while removing its UID-part
function safeMove { s=${1##*/}; s=${s%%,*}; mv -f $1 $2/$s; }

# Move all deleted messages to the Trash folder
echo Moving $(notmuch count --output=files --exclude=false tag:deleted AND NOT 
folder:Trash) \
 deleted messages to the Trash folder
for i in $(notmuch search --exclude=false --output=files tag:deleted AND NOT 
folder:Trash); do
safeMove $i ${MAILDIR}/Trash/cur
done

# Move all spam messages to the Spam folder
echo Moving $(notmuch count --output=files tag:spam AND NOT folder:Spam) \
 spam-marked messages to the Spam folder
for i in $(notmuch search --output=files tag:spam AND NOT folder:Spam); do
safeMove $i ${MAILDIR}/Spam/cur
done

# Move all archived messages from Inbox to Archive folder
echo Moving $(notmuch count --output=files folder:Inbox AND NOT tag:inbox) \
 archived messages from Inbox to Archive folder
for i in $(notmuch search --output=files folder:Inbox AND NOT tag:inbox); do
safeMove $i ${MAILDIR}/Arkiv/cur
done

echo Syncing with Webmail
mbsync twoway

echo Updating notmuch database
notmuch new --no-hooks
=== 8< ===
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch