Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set up a folder with DOS batch processing

Shulou Source: shulou.com Published: 2022-06-03 16:31:31 09月20日 Update

This article mainly introduces "how to use DOS batch to build a folder". In daily operation, I believe many people have doubts about how to use DOS batch to build a folder. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the question of "how to use DOS batch to build a folder." Next, please follow the editor to study!

Topic: setting up folders with DOS batch processing

Requirements: 1 require the establishment of a folder with the file name format "YYYY1-MM1-DD1 to YYYY2-MM2-DD2"

2 where YYYY1-MM1-DD1 is today's date; YYYY2-MM2-DD2 is the date four days later

Answer:

The code is as follows:

@ 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 modulus operator:%% DOS (%% in batch files Under the non-batch command line, use%) rem log folder name initial value set filelog=%date:~0,10% to rem subsequent date variable set / A yearly 0 set / A massif 0 set / A dong0 rem take DD two digits set / A dd=% date:~8,2% set / A ddp4=% dd% + 4 rem fetch date YYYYMMDD MM two digits set / A mm=% date:~5,2% set / A mmp1=% mm% + 1 rem fetch date YYYYMMDD YYYY in four digits set / A yyyy=% date:~0,4% set / A yyyyp1=% yyyy% + 1 set / A yymd=yyyy% 4 rem if it is a 31-day month 5,7 8) rem December special if% mm% equ 12 (if% ddp4% leq 31 (set / A yy% y% set / A masks% mm% set / A dudes% ddp4%) if% ddp4% gtr 31 (if% mmp1% gtr 12 (set / A y% y y% + 1 set / A m = 1 set / A d% ddp4-31) goto END) if% mm% equ 10 ( If% ddp4% leq 31 (set / A y% yy% set / A mm% set / A y% ddp4%) if% ddp4% gtr 31 (set / A y% y% set / A m% mm / A y% set / A d% d p 4-31) goto END) if% mm% equ 8 (if% ddp4% leq 31 (set / A y% y% set / A m=%mm) % set / A dwells% ddp4%) if% ddp4% gtr 31 (set / A yyy% set / A mm% set / A dudes% ddp4-31) goto END) if% mm% equ 7 (if% ddp4% leq 31 (set / A y% yy% set / A masks% mm% set / A dudes% ddp4%) if% ddp4% gtr 31 ( Set / A yy% yyy% set / A mm% mm p1% set / A y y% ddp4-31) goto END) if% mm% equ 5 (if% ddp4% leq 31 (set / A y% yy% set / A mm% set / A dice% ddp4%) if% ddp4% gtr 31 (set / A y% yyy% set / A masks% MMP1% set / A dice% ddp4% -31) goto END) if% mm% equ 3 (if% ddp4% leq 31 (set / A y% yy% set / A mm% set / A db% ddp4%) if% ddp4% gtr 31 (set / A y% yy% set / A m% mm p1% set / A d% ddp4-31) goto END) if% mm% equ 1 (if% ddp4%) Leq 31 (set / A y% yy% set / A mm% set / A d% ddp4%) if% ddp4% gtr 31 (set / A y% y% set / A m% mm p1% set / A d% ddp4-31) goto END) rem if it is a 30-day month (4. 9) if% mm% equ 11 (if% ddp4% leq 30 (set / A yyy% set / A y=%yyyy% mm% set / A dice% ddp4%) if% ddp4% gtr 30 (set / A yyy% set / A mm% set / A dice% ddp4-30) goto END) if% mm% equ 9 (if% ddp4% leq 30 (set / A y=%yyyy) % set / A masks% mm% set / A dwells% ddp4%) if% ddp4% gtr 30 (set / A yyy% set / A mills% set / A dudes% ddp4-30) goto END) if% mm% equ 6 (if% ddp4% leq 30 (set / A yyys% set / A masks% mm% set / A dudes% ddp4%) if % ddp4% gtr 30 (set / Ayy% yyy% set / A masked% mmp1% set / A dyed% ddp4-30) goto END) if% mm% equ 4 (if% ddp4% leq 30 (set / A yyy% set / A masked% mm% set / A dumped% ddp4%) if% ddp4% gtr 30 (set / A yyy% set / A masked% mmp1% Set / A dwells% ddp4-30) goto END) rem if it is 28 or 29 days of the month (2) if% mm% equ 2 (if% yymd% equ 0 (if% ddp4% leq 29 (set / A yyy% set / A mm% set / A dice% ddp4%) if% ddp4% gtr 29 (set / A yyy% set / A masks% mmp1% Set / A dwells% ddp4% 29) goto END) if% ddp4% leq 28 (set / A yy% y% set / A mm% set / A dwells% ddp4%) if% ddp4% gtr 28 (set / A y% y% set / A masks% MMP1% set / A dwells% ddp4-28)) rem portfolio folder name And set up a folder: END if% m% lss 10 set filelog=%filelog%%y%-0%m% if not% m% lss 10 set filelog=%filelog%%y%-%m% if% d% lss 10 set filelog=%filelog%-0%d% if not% d% lss 10 set filelog=%filelog%-%d% mkdir% filelog% to this The study on "how to set up a folder with DOS batch processing" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Files folders dates studies months operators operations names more help solutions practical special next code variables commands file names articles methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Microsoft Shulou Information Shulou Technology Shulou Tech Info