Youll need to make an alias that counts your windows and then have it change all of them $chan $window etc. Using while loops works great for this.