How To Create Postfix Maildir Directory’s Script
In my work i had to change from Postfix mailbox users to maildir users. Inside the home directory i had about 450 users directory that needed to create the maildir format inside. So i did this script.
#!/bin/bash
# Created by Pedro Oliveira
MYDIR="/home"
DIRS=`ls -l $MYDIR | egrep '^d' | awk '{print $9}'`
# "ls -l $MYDIR" = get a directory listing
# "| egrep '^d'" = pipe to egrep and select only the directories
# "awk '{print $8}'" = pipe the result from egrep to awk and print only the 8th field
# and now loop through the directories:
for DIR in $DIRS
do
echo ${DIR}
rm ${DIR}/.bash* -fr
rm ${DIR}/mail -fr
rm ${DIR}/.mozilla -fr
mkdir -p ${DIR}/Maildir/cur
mkdir -p ${DIR}/Maildir/new
mkdir -p ${DIR}/Maildir/tmp
chown -R ${DIR}:mail ${DIR}
done