Add mblaze maildir archiving script
This commit is contained in:
parent
a1d2af019f
commit
f7b99e07d1
1 changed files with 24 additions and 0 deletions
24
bin/mailarchive
Executable file
24
bin/mailarchive
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
>&2 echo "Usage: $0 <source maildir> <archive maildir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
src="$1"
|
||||
arch="$2"
|
||||
begin="2010"
|
||||
|
||||
if ! [ -d "$arch/cur" ]; then
|
||||
>&2 echo "Folder $arch does not appear to be a maildir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umask 700
|
||||
|
||||
for y in $(seq "$begin" "$(date '+%Y')" | sort -r); do
|
||||
mkdir -p "$arch/$y/cur" "$arch/$y/new" "$arch/$y/tmp"
|
||||
mails=$(mlist "$src" | mpick -t "date <= \"$y-12-31\" && date >= \"$y-01-01\" && date < \"-180d\"" 2> /dev/null)
|
||||
>&2 printf 'The year is %s. %s emails to sort\n' "$y" "$(echo "$mails" | wc -l)"
|
||||
echo "$mails" | mrefile "$arch/$y"
|
||||
done
|
Loading…
Reference in a new issue