* James Michael Fultz <croo...@gmail.com> [2009-09-25 18:55 -0400]:
[...]
> If all of your folders are mbox and therefore files, it wouldn't
> be difficult to do with some scripting.

Oops!  Realized I'd missed some things.

#! /bin/sh

archivedir=~/Mail-archive
date=$(date '+%Y-%m-%d')

cd ~/Mail && find . -type f -exec sh -c '
        subdir=${1%/*}
        mbox=${1##*/}
        if [ "$subdir" = "." ]
        then
                outputdir=$archivedir
        else
                outputdir=$archivedir/${subdir#./}
        fi
        mkdir -p "$outputdir" && archivemail --no-compress --date="$date" \
                --output-dir="$outputdir" --archive-name="$mbox" "$1"
        ' sh {} \;

Reply via email to