Had some trouble getting it to work though.
First of all, as stated in the above comment, line 386 has the wrong alias and should be air1 indeed. And I'd like to suggest three small adjustments on lines 463, 476 and 535 to put a QUOTENAME around the @indexname ...
ALTER INDEX ' + QUOTENAME(@indexname) +' ON [' + @schemaname
It appeared that someone in our organization came up with the excellent idea to put dots (.) in a couple of indexnames, obviously resulting in a failing command.
Looking forward to see what's going to happen over time and can't wait to read part 2.