Scenario
I'm switching IMAP client on a mail server for several thousands domains with following structure :
Mail folder location: /home/mail/domains
(just an example)
Maildir for domain1.com contains following folders: (again just an example)
.Sent.2002.May
.Sent.2002.June
.Personal.Home.Jack
Maildir for domain2.com contains
.Sent.2008.June
.Emails.Test.test2
Maildir for domain3.com contains
.Sent.2012.Files
.Archive.2014.May
Problem:
My new IMAP client throws an error whenever intermediate folder is not there. Example for domain1.com:
If .Sent.2002
folder doesn exist it will throw an error when I try to view .Sent.2002.May
Task
I need a script to:
- Find folders in
/home/mail/domains/$domain/Maildir/
with this naming pattern.$1.$2.$3
- Create intermediate folders
/home/mail/domains/$domain/.$1.$2/
- Chown
/home/mail/domains/$domain/.$1.$2/
to usermail
Tried it manually for one domain and the IMAP client error is gone.
Need help with the script. I'm not sure how to translate arguments from find to mkdir in this case, because folder names always vary.
You need something like:
Executing it here, I got: