Barry Scott <[email protected]> wrote:
>
>
> > On 22 Jan 2022, at 21:26, Chris Green <[email protected]> wrote:
> >
> > I have a script that walks a quite deep tree of mail messages to find
> > and archive old messages. I'm trying to convert it from mbox to
> > maildir (as I now store my mail in maildir format).
> >
> > So I need to test whether a point I have reached in the hierarchy is a
> > maildir mailbox or not. Using mbox format it's easy because 'folders'
> > are directories and mailboxes are files. However with maildir the
> > 'folders' have directories within them so the simple tree walking goes
> > down a level too far and finds 'folders' which aren't mailboxes called
> > 'cur', 'new' and 'tmp'.
> >
> > Is there any 'ready made' way in python to tell whether a directory is
> > a maildir mailbox? If not I suppose I'll simply have to check if
> > there are 'cur', 'new' and 'tmp' directories within the directory
> > which may or may not be a maildir.
>
> You do not need to walk the tree.
>
> The structure is
> Maildir/cur, new, tmp - The INBOX
> Maildir/<encoded-mail-folder>/cur, new, tmp
>
> The encoding prefixed with a "." and uses a "." between folder name parts.
>
> An example from my Maildir is ".Python.Users/" for a folder that client
> shows as Python/Users
>
> You can see this by doing:
>
> ls -a ~/Maildir
>
You're talking about one specific (and IMHO not very good) way of
creating a maildir hierarchy. Here's what I see on my system:-
chris@esprimo$ cd mail
/home/chris/mail
chris@esprimo$ ls -a
. .. Gm In Ju Li Tm folder
chris@esprimo$ ls -a folder
. apexLodge entertainment greville houseHome maxMum
reshapers tractor
.. archive family hardware internet money
riding travel
Scans boating france health isbd pcc
software ukraa
Shopping buySellAdmin friends holidays jrml personal
telecoms vehicles
chris@esprimo$ ls -a folder/Shopping
. cabin cycling garden maxine pets
stationery
.. car diy giftsEtc maxmum photography
telecoms
apexLodge clothesEtc electrical groupon medicine riding
toolstation
boat computer electronics houseHome motorcycle screwfix
books cpc food jrml music sportsEtc
No dot prefixes and my maildir hierarchy is a *real* directory hierarchy so
all the other file management utilities on my system can be used easily.
--
Chris Green
ยท
--
https://mail.python.org/mailman/listinfo/python-list