Hello,
Thanks a lot for your answers, I'm happy to have received such thoughtful replies. Like you both pointed out, and from what I get, Notmuch works with message-ids, and since it may happen that several files in different folders have the same message-id, it explains what I was seeing.
My goal was to try to sync somehow how emails on my computer are organized using Notmuch and its tags with folders on the IMAP servers of the many email accounts I'm syncing to my ~/mail dir, using mbsync. I guess this is a common endeavour some people want, so for example if you browse one of your email account using a webmail interface, or an app on your phone, then there is some continuity between how your emails are sorted on your computer and how you find them on other interfaces. But I also see that this isn't that simple to implement. Being centered on message-ids, Notmuch doesn't seem to easily be able to recognize on which email account an email is (like in cases where one of my email account send an email to another of my account, or when some of my accounts receive the same email from somewhere else... basically, when there are duplicates). I also found out that moving email files might disrupt mbsync, so it is another issue I would need to look at.
I also understand the important differences between organizing emails using tags, and using folders. I just wanted to see if, with some shell scripting, I could arrange something somewhat similar. But it seems harder to do than I hoped.
I am still new to Notmuch, I use it on Emacs, maybe my efforts weren't necessary, and so I will keep using it and see how my needs and preferences go.
Thanks again for your replies, much appreciated!
Renaud