2

I have successfully changed my mail imap agent from dovecot to courier-imap, for some required features, how ever i am facing a problem during the maildrop/seive directory structure where i need to move 10000 mailboxes to correct directory structure,

so what i need is a script that will convert to move like this

mv /var/vmail/[ domain ]/[ username ]/Maildir/* /var/vmail/[ domain ]/[ username ]/

and i dont want to run this command 10000 times, its troublesome, could you help with this,

thank you

skuli434
  • 77
  • 1
  • 1
  • 9
  • can you give a concrete example where domain and username have meaningful values? – hovanessyan Aug 15 '12 at 07:57
  • Thank you mv /var/vmail/skuliweb.com/test/Maildir/* /var/vmail/skuliweb.com/test mv /var/vmail/skuliweb.com/test2/Maildir/* /var/vmail/skuliweb.com/test2 – skuli434 Aug 15 '12 at 08:06
  • ok, so you will probably have to generate a list of all domains + all users - a file where on each line you have: domainuser; Than use a loop, where for each line of the generated file, you execute the above command with the appropriate values. – hovanessyan Aug 15 '12 at 08:10

1 Answers1

2
for dir in /var/vmail/*/*
do
  mv "$dir"/Mail/* "$dir"
done
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358