[K12OSN] script needed

Peter Scheie peter at scheie.homedns.org
Sat Jul 25 20:22:00 UTC 2009

I don't fully understand what you want to do here, but I'll take a stab at it 
and others can join in and hopefully we'll at least get you moving in the right 

# Define list of folders to ignore
ignore='.Sent .Trash .Drafts cur new tmp'

# loop through all users
for user in $(ls /home/); do
	# loop through each user's Maildir
	for file in $(ls -a /home/${user}/Maildir/); do
		# grep for each file name in $ignore list; if that fails--a
		# logical OR denoted by the double-pipe (||) then add the
		# file name to the courierimapsubscribed file
		# The slash at the end of the first line means 'continued on
		# next line';  alternatively, in a script the two lines could be
		# combined into one (without the slash then)
		(echo $ignore |grep $file >/dev/null) || \
		echo INBOX${file} >> /home/${user}/courierimapsubscribed
# End of script

I haven't test this, so I suggest you try it on a subset of users by changing

for user in $(ls /home/); do


for user in bob sally jim; do

replacing bob, sally, and jim with real user names just to make sure you get 
what you want, before letting it rip on all your users.  HTH


John Hansen wrote:
> I have converted from mbox to Maildir folders on my old server. I am moving
> the folders from my old mail server to my new mail server which is using
> Maildir.  The problem is my courierimapsubscribed file is unaware of the
> non-default folders the users have added themselves.  I need a script that can
> look at all the files in my existing Maildir folder that do
> not match the default folders (ie .Sent, .Trash, .Drafts, cur, new, tmp, etc)
> and then append those file names to courierimapsubscribed so that my imap
> clients will recognize them.  For example, say my user created a
> Maildir/.Folder1, I need the line INBOX.Folder1 appended to
> courierimapsubscribed.
> Can anyone help me come up with a script to do this? 
> Thanks.
> John

More information about the K12OSN mailing list