Code:
# require the local browser, otherwise abort the script
/require local
# display confirmation prompt
/confirm "Compress "%f" and then delete it?"
# display busybox to allow the user to abort the script
/busybox
# for-each item selected perform the following commands
{
#execute WinRAR with desired flags, adjust these flags to suite your own needs
/run "C:\Program Files\WinRAR\WinRAR.exe" "%lp" a -ibck -rv10 -m5 -s -rr -r -ep1 -ap "%f.rar" "%f"
#if WinRar fails with an error the next command does not execute
#delete the folder and everything within it.
/deletree %p%f
}