Shell Scripting sa-learn
I don't know much about shell scripting so I'm asking for a bit of help. Right now I use the bash shell, since I don't use any advanced features or anything. I'd like to automate the learning of sa-learn on my server. I use IMAP folders, and SpamAssassin assisted by procmail to manage my mail. I'd like mail that I move to the Junk folder (stuff not automatically moved there when tagged as spam by SA and directly delivered there by procmail) to be learned as Spam by spam assassin, that means invoking the sa-learn script. I would like to automate this process, but with one special addition, I would like the folder list to be dynamic (i.e. everytime the script runs it recognizes new folder, instead of hard coding them in.).Here is the directory structure:
/home/username/Maildir
-.Junk
-.Trash
-.Sent
-.Drafts
-.NEISA
etc.
I'd like it to run the command sa-learn --spam --no-sync .Junk/cur/ for the Junk folder, and then sa-learn --ham --no-sync for every other folder (folders all start with a ., there are some extra folders and files but those are not the mail files). After these commands are completed a single sa-learn --sync should update the tokens. I have experimented with the sa-learn --folders command, but it doesn't seem to work, mus be something with the leading '.'? Once I've got this script I'll set it to run at about 4am every morning, which is when I've typically gone through and sorted all my mail for the day.
Any help with this would be really appreciated! I've read the sa-learn documentation but its not very helpful.