Batch Bat- automatically create folders based on the current time

@echo off
set hour=%time:~0,2%
if %hour% leq 9 (
	md %date:~0,4%%date:~5,2%%date:~8,2%_0%time:~1,1%%time:~3,2%%time:~6,2%
) else (
	md %date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
)	
pause

[@echo off]
Run bat when I do not show specific information on each line cmd interface, if you need to debug, you can remove this sentence.

set hour=%time:~0,2%
The first two get the current time, and then assign this value to the hour; when the current time is less than 10, direct access% time: 0,1% will complain, so direct access to two, then later comparison.

if %hour% leq 9 (
The acquisition of the current time is compared with 9, if it is less than or equal to 9 on the need fill 0 in front of him; special attention, after comparing over this (must be in the same line together, (PS: I also I do not know why, may be a fixed format, if not here, then added, being given an incorrect format).

EQU - equal
NEQ - not equal
LSS - less than
LEQ - less than or equal
GTR - greater than
GEQ - greater than or equal to

md
Create a folder with

pause
It is a pause output

Published an original article · won praise 0 · Views 316

Guess you like

Origin blog.csdn.net/SomeOne75/article/details/104070902