#!/bin/bash set -e indir=$1 outdir=$2 test -n "$indir" || exit 1 test -n "$outdir" || exit 1 maildirmake() { dir=$1 mkdir $1 mkdir $1/new mkdir $1/cur mkdir $1/tmp chmod -R 700 $1 } cd $indir if test -d cache; then maildirmake $outdir find cache -print | while read i; do find $i -print | while read j; do cp $j $outdir/cur/`basename $i`-`basename $j` done done fi if test -d subfolders; then for i in subfolders/*; do $0 $i $outdir/`basename $i` done fi