Marking messages as read and refile

28 views
Skip to first unread message

Henrik Frisk

unread,
Jan 7, 2025, 9:02:37 AMJan 7
to mu-discuss
Hi everyone,

Is there a way to mark, say all messages from 2023, as read and move them into a separate folder? Something like the original question posed in this thread:


I guess marking as read is not absolutely necessary

Thanks
/henrik

Dirk-Jan C. Binnema

unread,
Jan 8, 2025, 2:02:02 AMJan 8
to mu-di...@googlegroups.com
I suppose the easiest may be to do it as a shell-command, using a
combination of 'mu find' and 'mu move'.

Kind regards,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
gpg: 6987 9CED 1745 9375 0F14 DA98 11DD FEA9 DCC4 A036

Henrik Frisk

unread,
Jan 8, 2025, 5:13:36 AMJan 8
to mu-di...@googlegroups.com
Den ons 8 jan. 2025 kl 08:02 skrev Dirk-Jan C. Binnema <dj...@djcbsoftware.nl>:
On Tuesday Jan 07 2025, Henrik Frisk wrote:

> Hi everyone,
>
> Is there a way to mark, say all messages from 2023, as read and move them
> into a separate folder? Something like the original question posed in this
> thread:
>
> https://groups.google.com/g/mu-discuss/c/bgQmCy7m9uc/m/YzB2A-eZBAAJ
>
> I guess marking as read is not absolutely necessary

I suppose the easiest may be to do it as a shell-command, using a
combination of 'mu find' and 'mu move'.

Right, that makes sense. Is it possible o change the mark of a message with mu?

/Henrik

Dirk-Jan C. Binnema

unread,
Jan 8, 2025, 12:18:08 PMJan 8
to mu-di...@googlegroups.com
You can change the flags for a message (such as the read flag) with the
--flags parameter to 'mu move'. See the man-page.

Henrik Frisk

unread,
Jan 9, 2025, 2:58:40 AMJan 9
to mu-di...@googlegroups.com
Den ons 8 jan. 2025 kl 18:18 skrev Dirk-Jan C. Binnema <dj...@djcbsoftware.nl>:
On Wednesday Jan 08 2025, Henrik Frisk wrote:

> Den ons 8 jan. 2025 kl 08:02 skrev Dirk-Jan C. Binnema <dj...@djcbsoftware.nl
>>:
>
>> On Tuesday Jan 07 2025, Henrik Frisk wrote:
>>
>> > Hi everyone,
>> >
>> > Is there a way to mark, say all messages from 2023, as read and move them
>> > into a separate folder? Something like the original question posed in
>> this
>> > thread:
>> >
>> > https://groups.google.com/g/mu-discuss/c/bgQmCy7m9uc/m/YzB2A-eZBAAJ
>> >
>> > I guess marking as read is not absolutely necessary
>>
>> I suppose the easiest may be to do it as a shell-command, using a
>> combination of 'mu find' and 'mu move'.
>
>
> Right, that makes sense. Is it possible o change the mark of a message with
> mu?

You can change the flags for a message (such as the read flag) with the
--flags parameter to 'mu move'. See the man-page.
 
Sorry about that. I did read the man page but misunderstood it. Sorry about that, and thanks for the help! This is exactly what I was looking for.

/Henrik


 

Dirk-Jan C. Binnema

unread,
Jan 9, 2025, 11:14:11 AMJan 9
to mu-di...@googlegroups.com
On Thursday Jan 09 2025, Henrik Frisk wrote:
>>
>> You can change the flags for a message (such as the read flag) with the
>> --flags parameter to 'mu move'. See the man-page.
>>
>
> Sorry about that. I did read the man page but misunderstood it. Sorry about
> that, and thanks for the help! This is exactly what I was looking for.

Ah, good. Updates to the docs are always welcome, including pointing
out where they are not clear.

Henrik Frisk

unread,
Jan 21, 2025, 8:53:59 AMJan 21
to mu-di...@googlegroups.com
Den tors 9 jan. 2025 kl 17:14 skrev Dirk-Jan C. Binnema <dj...@djcbsoftware.nl>:
On Thursday Jan 09 2025, Henrik Frisk wrote:

Ah, good. Updates to the docs are always welcome, including pointing
out where they are not clear.
 I've been reading the man page a couple of times and I have to say that I find it very clear. Of course, now I know what to look for so my horizon was already expanded. Nevertheless, I think me not understanding this the first time is on me, not the text.

Thanks again for excellent software!

/Henrik

Henrik Frisk

unread,
Mar 9, 2025, 4:50:08 AMMar 9
to mu-di...@googlegroups.com
>>
>> > Hi everyone,
>> >
>> > Is there a way to mark, say all messages from 2023, as read and move them
>> > into a separate folder? Something like the original question posed in
>> this
>> > thread:
>> >
>> > https://groups.google.com/g/mu-discuss/c/bgQmCy7m9uc/m/YzB2A-eZBAAJ
>> >
>> > I guess marking as read is not absolutely necessary
>>
>> I suppose the easiest may be to do it as a shell-command, using a
>> combination of 'mu find' and 'mu move'.
>
>
> Right, that makes sense. Is it possible o change the mark of a message with
> mu?

You can change the flags for a message (such as the read flag) with the
--flags parameter to 'mu move'. See the man-page.

I didn't get around to deal with this until now. One question, how can I get mu find to format the input so that i can either pipe it or use int in the mu move command? I can of course write a script and reformat the plain output of mu find, but before I do I wanted to check if I'm missing something obvious!

 Best,
/Henrik

Dirk-Jan C. Binnema

unread,
Mar 11, 2025, 3:50:33 AMMar 11
to mu-di...@googlegroups.com
See the `--exec' option for `mu find'. Or alternatively, use `--fields=l'

Henrik Frisk

unread,
Mar 12, 2025, 10:20:55 AMMar 12
to mu-di...@googlegroups.com
Den tis 11 mars 2025 kl 08:50 skrev Dirk-Jan C. Binnema <dj...@djcbsoftware.nl>:
On Sunday Mar 09 2025, Henrik Frisk wrote:

>>>
>
>> >> > Hi everyone,
>> >> >
>> >> > Is there a way to mark, say all messages from 2023, as read and move
>> them
>> >> > into a separate folder? Something like the original question posed in
>> >> this
>> >> > thread:
>> >> >
>> >> > https://groups.google.com/g/mu-discuss/c/bgQmCy7m9uc/m/YzB2A-eZBAAJ
>> >> >
>> >> > I guess marking as read is not absolutely necessary
>> >>
>> >> I suppose the easiest may be to do it as a shell-command, using a
>> >> combination of 'mu find' and 'mu move'.
>> >
>> >
>> > Right, that makes sense. Is it possible o change the mark of a message
>> with
>> > mu?
>>
>> You can change the flags for a message (such as the read flag) with the
>> --flags parameter to 'mu move'. See the man-page.
>>
>> I didn't get around to deal with this until now. One question, how can I
> get mu find to format the input so that i can either pipe it or use int in
> the mu move command? I can of course write a script and reformat the plain
> output of mu find, but before I do I wanted to check if I'm missing
> something obvious!

See the `--exec' option for `mu find'. Or alternatively, use `--fields=l'

Thanks!

I'm running into problems though. If I run 

$ mu find d:20240401..20240501 maildir:"/work/*" | wc -l

I get 617.

If I run the same search with --exec like this:

$ mu find d:20240401..20240501 maildir:"/work/*" --exec='mu move --flags -N+S' | wc -l

I get:
error: Source is not a readable file
error: shell command exited with exit-code 1
223

This is consistent with other searches, it ends with an exit-code 1

What can I do to track down the error?

/Henrik

Dirk-Jan C. Binnema

unread,
Mar 14, 2025, 2:34:46 AMMar 14
to mu-di...@googlegroups.com
On Wednesday Mar 12 2025, Henrik Frisk wrote:


> I'm running into problems though. If I run
>
> $ mu find d:20240401..20240501 maildir:"/work/*" | wc -l
>
> I get 617.
>
> If I run the same search with --exec like this:
>
> $ mu find d:20240401..20240501 maildir:"/work/*" --exec='mu move --flags
> -N+S' | wc -l
>
> I get:
> error: Source is not a readable file
> error: shell command exited with exit-code 1
> 223
>
> This is consistent with other searches, it ends with an exit-code 1
>
> What can I do to track down the error?

Use small steps. First your find, then `--exec echo`, then perhaps echo
your move command, and then the actually move and only then use the
pipe.

Henrik Frisk

unread,
Apr 21, 2025, 5:47:56 AMApr 21
to mu-di...@googlegroups.com
Den fre 14 mars 2025 kl 07:34 skrev Dirk-Jan C. Binnema <dj...@djcbsoftware.nl>:
On Wednesday Mar 12 2025, Henrik Frisk wrote:


> I'm running into problems though. If I run
>
> $ mu find d:20240401..20240501 maildir:"/work/*" | wc -l
>
> I get 617.
>
> If I run the same search with --exec like this:
>
> $ mu find d:20240401..20240501 maildir:"/work/*" --exec='mu move --flags
> -N+S' | wc -l
>
> I get:
> error: Source is not a readable file
> error: shell command exited with exit-code 1
> 223
>
> This is consistent with other searches, it ends with an exit-code 1
>
> What can I do to track down the error?

Use small steps. First your find, then `--exec echo`, then perhaps echo
your move command, and then the actually move and only then use the
pipe.
I have finally had the time to try to track this down. I'm not sure this particular issue is the only problem I'm having, but there is probably something wrong with my process here. The following command works:

$ mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move --flags -N+S'

It has one single match and it is marked as Seen. 'mu find' still finds the message as expected when I do:

$ mu find s:Proton m:/fsdata/* d:20250415 --exec echo
/Users/XXX/.maildir/fsdata/Inbox/cur/1744711725.1f94dc13862cef4a5.Henrik-Frisks-Mac:2,S

But this command fails:

mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move /fsdata/Archive'
error: Source is not a readable file
error: shell command exited with exit-code 1

Running the same mu move but with the full path to the message above works fine

$ mu move /Users/XXX/.maildir/fsdata/Inbox/cur/1744711725.1f94dc13862cef4a5.Henrik-Frisks-Mac:2,S /fsdata/Archive'

Do I have to construct the '--exec mu move ' command differently for moveing the meessage to another directory?

Thanks!
/Henrik


Dirk-Jan C. Binnema

unread,
Apr 23, 2025, 4:53:45 AMApr 23
to mu-di...@googlegroups.com
Hi Henrik,

On Monday Apr 21 2025, Henrik Frisk wrote:

> I have finally had the time to try to track this down. I'm not sure this
> particular issue is the only problem I'm having, but there is probably
> something wrong with my process here. The following command works:
>
> $ mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move --flags -N+S'
>
> It has one single match and it is marked as Seen. 'mu find' still finds the
> message as expected when I do:
>
> $ mu find s:Proton m:/fsdata/* d:20250415 --exec echo
> /Users/XXX/.maildir/fsdata/Inbox/cur/1744711725.1f94dc13862cef4a5.Henrik-Frisks-Mac:2,S
>
> But this command fails:
>
> mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move /fsdata/Archive'
> error: Source is not a readable file
> error: shell command exited with exit-code 1
>
> Running the same mu move but with the full path to the message above works
> fine
>
> $ mu move
> /Users/XXX/.maildir/fsdata/Inbox/cur/1744711725.1f94dc13862cef4a5.Henrik-Frisks-Mac:2,S
> /fsdata/Archive'
>
> Do I have to construct the '--exec mu move ' command differently for
> moveing the meessage to another directory?

You're almost there, but note that e.g
mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move /fsdata/Archive'
fails because this would execute
mu move /fsdata/Archive <path>
which is the wrong order, hence the errors.

So use something like:
for m in $(mu find <your-query> --exec echo); do echo "mu move $m /foo/bar"; done
(change <your-query> / the 'do' to actually do what you want)

Henrik Frisk

unread,
Apr 28, 2025, 3:29:12 AMApr 28
to mu-di...@googlegroups.com
Yes of course. I was confused by the fact that this:

mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move -N+S'

appeared to be working, but I'm guessing now it didn't, it just didn't throw any errors.

Thanks again!

Dirk-Jan C. Binnema

unread,
Apr 28, 2025, 4:13:08 AMApr 28
to mu-di...@googlegroups.com
On Monday Apr 28 2025, Henrik Frisk wrote:

>>
>> Yes of course. I was confused by the fact that this:
>
> mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move -N+S'
>
> appeared to be working, but I'm guessing now it didn't, it just didn't
> throw any errors.

The situation there is a little different as there is no target path to
be confused with the source.

(I guess I could add some explicit --target=... to `mu move` to avoid
the confusion).

Henrik Frisk

unread,
May 6, 2025, 5:35:20 AMMay 6
to mu-di...@googlegroups.com
Den mån 28 apr. 2025 kl 10:13 skrev Dirk-Jan C. Binnema <dj...@djcbsoftware.nl>:
On Monday Apr 28 2025, Henrik Frisk wrote:

>>
>> Yes of course. I was confused by the fact that this:
>
> mu find s:Proton m:/fsdata/* d:20250415 --exec 'mu move -N+S'
>
> appeared to be working, but I'm guessing now it didn't, it just didn't
> throw any errors.

The situation there is a little different as there is no target path to
be confused with the source.

(I guess I could add some explicit --target=... to `mu move` to avoid
the confusion).

Maybe, but it's pretty clear now I think. I think the man files are really good too once I start to undeerstand better.

For reference, here's the final script which worked really well or me, moving 50k+ messages (I did a year at a time), and then mu init and mu index:

#!/bin/bash
mdir="maildir:/work/INBOX"
seen="--flags -N+S"
archive=/work/Archive
date=20250101..20250601

for m in $(mu find $date $mdir --exec echo);
do
    mu move $m $seen \
    mu move $m $archive;
done

Thanks again for great software!
/h

Henrik Frisk

unread,
May 6, 2025, 6:30:23 AMMay 6
to mu-di...@googlegroups.com
#!/bin/bash
mdir="maildir:/work/INBOX"
seen="--flags -N+S"
archive=/work/Archive
date=d:20250101..20250601


for m in $(mu find $date $mdir --exec echo);
do
    mu move $m $seen;
#    mu move $m $archive;
done
Sorry, two small typos. The date parameter obviously needs to be preceeded by d: or date:  and the two mu move commands needs to be run en sequence because the variable $m is not valid after the forst move command.
Reply all
Reply to author
Forward
0 new messages