Need some AppleScript help moving messages

In the following, for a non-Gmail account, the selected messages move from a source mailbox to a target mailbox. But with a Gmail account, a copy is made in the target, but it's still listed in the source. Any ideas?

[added later: It appears that Gmail does not really use mailboxes. It uses "labels". If a message is tagged with the label "BSOE" then Apple Mail presents it as contained in a mailbox "BSOE". This doesn't help me at all, since I have no way to access the label or change the label of a mail message. Does anyone know how to do this?]

experiment to move message to a folder - 2.kmmacros (2.8 KB)