i've gotten around this by naming my images with sequential numbers. then you can just have a constant you change that holds the number of the largest image and you can use that to construct your loop ...
現在アクセス不可の可能性がある結果が表示されています。
アクセス不可の結果を非表示にする現在アクセス不可の可能性がある結果が表示されています。
アクセス不可の結果を非表示にする