Sync Mail Folders

Here’s an to sync IMAP mail folders (one way only, although it’s trivial to extend it to sync both ways):

tell application Mail
  set destination to (every message in mailbox Archive in account Home whose deleted status = false)
  set destinationIDs to {}
  set d to a reference to destinationIDs
  repeat with eachMessage in destination
    set i to message id of eachMessage
    copy i to the end of d
  end repeat
  set origin to (every message in mailbox Archive in account News whose deleted status = false)
  repeat with eachMessage in origin
    set i to message id of eachMessage
      if d does not contain i then
        duplicate eachMessage to (mailbox Archive in account Home)
      end if
  end repeat
end tell

(I use this to back up my archive to another IMAP folder for safekeeping, hence my being happy with it only syncing one way, but enterprising folk will love extending it into a full-blown IMAP sync tool..)