[imapfilter-devel] Process All Sub-Folders

Lefteris Chatzimparmpas lefcha at hellug.gr
Thu Jan 3 23:42:22 EET 2008


On Thu, Jan 03, 2008 at 01:30:48PM -0500, Ropetin Again wrote:
> I'm sure I'm missing something obvious, but I can't seem to find a way
> to 'process all sub-folders'.  I.e.  I have a mailbox structure;
> 
> Inbox
> Inbox.Stuff
> Inbox.Stuff.MoreStuff
> Inbox.Stuff.OtherStuff
> Inbox.Stuff.OtherStuff.MoreOtherStuff
> Inbox.OldStuff
> 
> I would like to run a query on Inbox.Stuff and all the folders
> underneath it, and move the matched messages to Inbox.OldStuff.  Is
> there a simple way to do this without manually specifying each folder?
> 
> Thanks,
> Ropetin

Happy New Year everyone!

You could do something like this:

  options.namespace = false  -- have better control over mailbox names

  mailboxes = blue:list_all('INBOX.Stuff', '*')
  for _, m in pairs(mailboxes) do
      messages = blue[m]:select_all()  -- some searching function here
      blue[m]:move_messages(blue['INBOX.OldStuff'], messages)
  end

Lefteris




More information about the Imapfilter-devel mailing list