2017-05-20 25 views
0

我有這個批處理文件如何僅將圖像上的循環從100更改爲199?

 for %%f in (image1*.jpg) do { 
    code here.. 
    } 

我的問題是,在「圖像* 1」的獲取圖像,從100到199和1000〜1999

Iwant到我的循環只從100得到的圖像到199和另一個循環獲得圖像從1000到1099

如何做到這一點?

+2

使用計數循環'爲/ L %%下,在(100,1,199)DO(回波圖像%% C.JPG)' – LotPings

+0

但我循環上的圖像不是這個數會考慮圖像? – Moudiz

+0

如果數字沒有差距,有什麼區別?如果存在間隙,則插入一個「If exists」圖像%% c.jpg「whatever' – LotPings

回答

1
for /l %%c in (100,1,199) Do If exist image%%c.jpg (
code here... 
) 

一種不同的方法:

For /f "delims=" %%f in (
    'Dir /B/A-D image1*.jpg ^|findstr /i "^image1[0-9][0-9]\.jpg$"' 
) Do (
code here... 
) 

與正則表達式的FINDSTR將舒爾從1開始數有3個地方。對於1000〜1999加一次[0-9]