This is a simple, bespoke AppleScript I made to help with an annoying problem wherein plugging in multiple external monitors to my MacBook Pro almost always results in their rotation being incorrect. This script simply opens up the Display pane of System Preferences, and manually sets the rotation to the correct values.
This is currently setup to work specifically with my particular setup, so it most likely won't work for you as is. Maybe I'll make it more dynamic someday, but if you want to use it, you'll have to edit some things, namely the names of the windows (mine are "DELL P2717H (1)").