Hi Renaud, I was able to see similar behavior in my own mail store. And I agree that this behavior is confusing! The documentation for the --files option of notmuch search documents the cause (and predicts that this will be confusing): Note that each message may have multiple filenames associ‐ ated with it. All of them are included in the output (un‐ less limited with the --duplicate=N option). This may be particularly confusing for folder: or path: searches in a specified directory, as the messages may have duplicates in other directories that are included in the output, al‐ though these files alone would not match the search. For my case, I ran a little shell-script one-liner to verify that the duplicated messages where causing this behavior. This one-liner will loop over each message-id matched by the path: pattern and will print all filenames for each: for id in $(notmuch search --output=messages path:YOUR_PATTERN_HERE); do \ echo "=== $id ==="; \ notmuch search --output=files $id; \ echo; \ done If you run the above with your own pattern substituted for YOUR_PATTERN_HERE I imagine you'll see the same thing I did, (that for any filename paths that don't match the pattern, they have a message-id which _also_ appears in the database for another path that _does_ match the pattern). In general, I'm not a fan of software documenting "this may be confusing". That suggests the authors of the documentation know that the software is not behaving as the user intends, so it would be preferable for the software to behave as intended. That said, I also understand the implementation details that lead to this behavior. So I wouldn't be opposed to improving the behavior of notmuch to reduce this behavior, (but that implementation might not be trivial or even fully feasible). Hopefully, the duplicate message-id issue explains what you're seeing. And further, I hope that you just being aware of this issue gives you a way to cleanly solve your problem, (either by filtering the output of "notmuch search --output=files" or by instead doing something along the lines of the "notmuch search --output=messages" approach I show above). Let us know if you need anything further. And good luck! -Carl On Mon, May 13 2024, Renaud B. wrote: > Hello, > > If I do: > > notmuch search --output=files path:rb@kosmopolis.ca/** > > I get the following results: > > /home/rb/.mail/rb@kosmopolis.ca/Inbox/cur/1715564710.62398_2.tp,U=2:2,S > /home/rb/.mail/ > contact@renaudbussieres.com/Inbox/cur/1715541329.42568_1.tp,U=2:2,S > /home/rb/.mail/rb@kosmopolis.ca/Sent/cur/1715564710.62398_6.tp,U=4:2,S > /home/rb/.mail/ > contact@renaudbussieres.com/Inbox/cur/1714698543.61892_1.tp,U=1:2,S > /home/rb/.mail/rb@kosmopolis.ca/Inbox/cur/1715564710.62398_1.tp,U=1:2,S > /home/rb/.mail/rb@kosmopolis.ca/Trash/cur/1715564710.62398_7.tp,U=1:2,S > /home/rb/.mail/rb@kosmopolis.ca/Sent/cur/1715564710.62398_5.tp,U=3:2,S > /home/rb/.mail/rb@kosmopolis.ca/Sent/cur/1715564710.62398_4.tp,U=2:2,S > /home/rb/.mail/rb@kosmopolis.ca/Sent/cur/1715564710.62398_3.tp,U=1:2,S > > As you can see, two of these files are located under "~/.mail/ > contact@renaudbussieres.com/". It shouldn't be the case, because of the " > path:rb@kosmopolis.ca/**" which means explicitly "everything under the > ~/.mail/rb@kosmopolis.ca/ directory" (if I understand correctly). > > Likewise, if I do: > > notmuch search --output=files path:contact@renaudbussieres.com/** > > It returns: > > /home/rb/.mail/ > contact@renaudbussieres.com/Inbox/cur/1715541329.42568_1.tp,U=2:2,S > /home/rb/.mail/rb@kosmopolis.ca/Sent/cur/1715564710.62398_6.tp,U=4:2,S > /home/rb/.mail/ > contact@renaudbussieres.com/Inbox/cur/1714698543.61892_1.tp,U=1:2,S > /home/rb/.mail/rb@kosmopolis.ca/Inbox/cur/1715564710.62398_1.tp,U=1:2,S > > Again, there are 2 false results. > > Do you have any idea what's happening? My goal is simply to get all emails > under each directories in my "~/.mail" folder, one at a time. > > Thanks, > Renaud B. > _______________________________________________ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-leave@notmuchmail.org _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org