把windows bat 进行到底(多重循环 时间循环 自动化)
本批处理脚本,涉及到以下几个方面
1.两重循环
2.有效处理日期
3.检查每天的日志文件是否存在,日志文件文件名称为yyyymmdd.log
4.本文仅仅是一个范例,各位可以自己编写自己的脚本,来满足自己的需求.
+++++++++++++++++checksum.bat+++++++++++++++++
echo 检查每天的日志文件>result.txt
@echo off
for %%i in (01,02,03,04,05,06,07) do @call checksum1.bat %%i
type result.txt
+++++++++++++++++checksum1.bat+++++++++++++++++
if "%1"="" goto end
goto %1
:01
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do call checksum0.bat %1 %%j
goto end
:02
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28) do call checksum0.bat %1 %%j
goto end
:03
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do call checksum0.bat %1 %%j
goto end
:04
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) do call checksum0.bat %1 %%j
goto end
:05
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do call checksum0.bat %1 %%j
goto end
:06
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) do call checksum0.bat %1 %%j
goto end
:07
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do call checksum0.bat %1 %%j
goto end
:08
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do call checksum0.bat %1 %%j
goto end
:09
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) do call checksum0.bat %1 %%j
goto end
:10
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do call checksum0.bat %1 %%j
goto end
:11
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,30) do call checksum0.bat %1 %%j
goto end
:12
@echo ==============月份:20%1月==================>>result.txt
for %%j in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do call checksum0.bat %1 %%j
goto end
:end
echo on
+++++++++++++++++checksum0.bat+++++++++++++++++
rem echo 日期 %1 %2:
if exist 2007%1%2.log echo 2007%1%2.log >>result.txt
+++++++++++++++++一个运行结果+++++++++++++++++
D:\>type result.txt
检查每天的日志文件
==============月份:2001月==================
==============月份:2002月==================
==============月份:2003月==================
==============月份:2004月==================
==============月份:2005月==================
==============月份:2006月==================
20070605.log
==============月份:2007月==================
20070731.log
[ 本帖最后由 comsyschen@163.com 于 2007-8-22 13:38 编辑 ]