John,
You should be able to do something like this:
[Code moderated as per the Forum Rules. Please use the pastebin]
I’m sure there are several other filters or actions you could hook into rather than wp_insert_post_data — you’ll have to dig through the codex to figure out which one best suites your situation.