There are many ways this could be condensed, but either you will lose some functional detail (as examplified by BlankMinded), or you will require some external support (typically in Lua form).
For this last, I suggest going over my Macro guide stickied at the top of this sub-forum (
The New Macro Guide). It covers many advanced features including creating your own slash commands. The links in the guide are dated and will likely not work, but the rest is fine.
Anyway, with a bit of Lua support, your entire macro could boil down to a single slash command.