#!/bin/sh # This script finds all the flagged email in a Maildir and symlinks them to a 'flagged' folder in the Maildir. # To run it every 5 minutes, for instance, add the following to the user's crontab: # # */5 * * * * /home/greenfly/bin/flag-folder MAILDIR='/home/greenfly/Maildir/' # path to your maildir FLAGGED="${MAILDIR}/.flagged/cur" # path to your (precreated) flagged folder cd $FLAGGED rm ${FLAGGED}/* # find all of the files in the maildir, then search for flagged files (files with a 'F' after the last comma in the filename) and symlink them find ${MAILDIR} -type f | perl -ne '$foo = ""; $foo = (split ",", $_)[-1] if(/,/); if($foo =~ /F/){chomp; system "ln -s $_ .\n";}'