用dos批处理实现建立文件夹(Building folders with DOS batch processing).doc
文本预览下载声明
用dos批处理实现建立文件夹(Building folders with DOS batch processing)
Requirements: 1 requires the establishment of file names in the form of YYYY1-MM1-DD1 to YYYY2-MM2-DD2 folder
2, where YYYY1-MM1-DD1 is todays date; YYYY2-MM2-DD2 is four days later
Answer:
@echo off
REM comparison operator: EQU - equal to NEQ - not equal to LSS - less than LEQ - less than or equal to GTR - greater than GEQ - greater than or equal to
REM modulo operator: operator from DOS% (batch file in%, non batch command line%)
REM log folder name initial value
Set filelog=%date:~0,10% to
REM variables for subsequent dates
Set /A y=0
Set /A m=0
Set /A d=0
REM takes the DD two in the date YYYYMMDD
Set /A dd=%date:~8,2%
Set, /A, ddp4=,%dd% + 4
REM takes the MM two in the date YYYYMMDD
Set /A mm=%date:~5,2%
Set, /A, mmp1=,%mm% + 1
REM takes the YYYY four in the date YYYYMMDD
Set /A yyyy=%date:~0,4%
Set, /A, yyyyp1=,%yyyy% + 1
Set /A yymd=yyyy, 4
Rem, if its 31 months (1,3,5,7,8,10,12)
REM special December
If%mm% equ 12
If%ddp4% Leq 31
Set /A y=%yyyy%
Set /A m=%mm%
Set /A d=%ddp4%
)
If%ddp4% GTR 31
If%mmp1% GTR 12
Set /A y=%yyyy% + 1
Set /A m= 1
Set /A d=%ddp4% - 31
)
)
Goto END
)
If%mm% equ 10
If%ddp4% Leq 31
Set /A y=%yyyy%
Set /A m=%mm%
Set /A d=%ddp4%
)
If%ddp4% GTR 31
Set /A y=%yyyy%
Set /A m=%mmp1%
Set /A d=%ddp4% - 31
)
Goto END
)
If%mm% equ 8
If%ddp4% Leq 31
Set /A y=%yyyy%
Set /A m=%mm%
Set /A d=%ddp4%
)
If%ddp4% GTR 31
Set /A y=%yyyy%
Set /A m=%mmp1%
Set /A d=%ddp4% - 31
)
Goto END
)
If%mm% equ 7
If%ddp4% Leq 31
Set /A y=%yyyy%
Set /A m=%mm%
Set /A d=%ddp4%
)
If%ddp4% GTR 31
Set /A y=%yyyy%
Set /A m=%mmp1%
Set /A d=%ddp4% - 31
)
Goto END
)
If%mm% equ 5
If%ddp4% Leq 31
Set /A y=%yyyy%
Set /A m=%mm%
Set /A d=%ddp4%
)
If%ddp4% GTR 31
Set /A y=%yyyy%
Set /A m=%mmp1%
Set /A d=%ddp4% - 31
)
Goto END
)
If%mm% equ 3
If%ddp4% Leq 31
Set /A y=%yyyy%
Set /A m=%mm%
Set /A d=%ddp4%
)
If%ddp4% GTR 31
Set /A y=%yyyy%
Set /A m=%mmp1%
Set /A d=%ddp4% - 31
)
Goto END
)
If%mm% equ 1
If%ddp4% Leq 31
Set /A y=%yyyy%
Set
显示全部