require [ "date", "fileinto", "mailbox", "variables" ];

if currentdate :matches "year"  "*" { set "year"  "${1}"; }
if currentdate :matches "month" "*" { set "month" "${1}"; }

if exists "List-ID" {
  if header :matches "List-ID" "*<*.*.*.*>*" {
    set "list"   "${2}";
    set "domain" "${4}";
  }
  elsif header :matches "List-ID" "*<*.*.*>*" {
    set "list"   "${2}";
    set "domain" "${3}";
  }
  fileinto :create "Listes+${domain}+${list}+${year}+${month}";
  stop;
}