% Although it could be done better in bash, I needed a quick script do download a series of images from a book. startUrl='http://img.phombo.com/img1/photocombo/72/Ep'; midUrl='-'; endUrl='.jpg'; for k=1:6 fCount=0; for i = 0:100 fName='--'; mcnt=num2str(k,'%01u'); scnt=num2str(i,'%03u'); try fName=urlwrite([startUrl mcnt midUrl scnt endUrl],['img_' mcnt '_' scnt '.jpg']); end disp(fName) disp([mcnt '-' scnt]) if strcmp(fName,'--') fCount=fCount+1; if fCount>15 break end end end end