reset batch size after each iteration and use basename correctly