简体   繁体   中英

how to loop through files with some number format using batch script?

I would like to iterate through some files. The difference in those files are just a number appended to it.

I want to do something like this -

SET /A COUNT=1
for %%I in (\\bay-e!COUNT!\e$\sat\logs\BAY-E!COUNT!.Log.2012-03-  12.log) do (
@echo %%~zI
SET /A COUNT+=1
)

I do not see this working. Is there any other way?

I assume you are on Windows. The way to do it is something like

FOR /L %%G IN (1,1,100) DO ECHO \\bay-%%G\e$\sat\logs\BAY-%%G.log

There are very useful unofficial Windows .BAT docs, here is the one for FOR/L: http://ss64.com/nt/for_l.html

Note : On the command line, use %G, only a .BAT file needs %%G

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM