Say you have a directory with tens of thousands of messages in it. And you want to separate the spam from the non-spam.
Specifically, you would like to:
- Run spamassassin against the directory, tagging each message with an X-Spam-Flag: YES if it thinks it's spam
- Have a tcsh shell or perl one-liner grep all mail with the flag and move those mails to /tmp/spam
What command can you run to accomplish this? For example, some pseudocode:
/usr/local/bin/spamassassin -eL ./Maildir/cur/* | grep "X-Spam-Flag: YES" | mv %1 /tmp/spam
Your first guess was pretty close :-)
I made a bash script to scan a whole maildir against spam
Save this as mailcleanup.sh somewhere, put the path of the folder you want to scan as DIR, set it +x and run it.
Good luck!
Ended up doing this the long way, without using spamassassin: