How can I move mails in an IMAP mailbox?

I want to filter and sort incoming mails in my IMAP account.

I am able to start a workflow by an IMAP trigger, but I do not know how to filter (by a branch? If yes how?) and then finally move the mail to a subfolder.

Has anyone an idea how I can start? Thanks in advance.

Uwe