[방법 1]
@set YEAR=%date:~0,4%
@set MONTH=%date:~5,2%
@set DAY=%date:~8,2%
@set HOUR=%time:~0,2%
@set MINUTE=%time:~3,2%
@set SECOND=%time:~6,2%
@set POSTFIX=%YEAR%-%MONTH%-%DAY%_%HOUR%-%MINUTE%-%SECOND%
mkdir "log_%POSTFIX%"
cd "log_%POSTFIX%"
@set MONTH=%date:~5,2%
@set DAY=%date:~8,2%
@set HOUR=%time:~0,2%
@set MINUTE=%time:~3,2%
@set SECOND=%time:~6,2%
@set POSTFIX=%YEAR%-%MONTH%-%DAY%_%HOUR%-%MINUTE%-%SECOND%
mkdir "log_%POSTFIX%"
cd "log_%POSTFIX%"
[방법 2]
@set YEAR=%date:~0,4%
@set MONTH=%date:~5,2%
@set DAY=%date:~8,2%
@set HOUR=%time:~0,2%
@set MINUTE=%time:~3,2%
@set SECOND=%time:~6,2%
@set POSTFIX=%YEAR%-%MONTH%-%DAY%_%HOUR%-%MINUTE%-%SECOND%
mkdir "log_%POSTFIX%"
cd "log_%POSTFIX%"
@set MONTH=%date:~5,2%
@set DAY=%date:~8,2%
@set HOUR=%time:~0,2%
@set MINUTE=%time:~3,2%
@set SECOND=%time:~6,2%
@set POSTFIX=%YEAR%-%MONTH%-%DAY%_%HOUR%-%MINUTE%-%SECOND%
mkdir "log_%POSTFIX%"
cd "log_%POSTFIX%"
추가 Cammand창의 언어 코드 변환하기
CHCP 437 <-- 영문으로 변경
CHCP 949 <-- 한글로 변경
[출처 : https://serverfault.com/ ]
파워셀을 이용한 방식
@echo off
for /f %%i in ('powershell ^(get-date^).DayofWeek') do set week=%%i
echo %week%
*Output
Sunday
for /f %%i in ('powershell ^(get-date^).DayofWeek') do set week=%%i
echo %week%
*Output
Sunday
#현재일에서 하루를 빼 줄 경우
for /f %%i in ('powershell ^(get-date^).AddDay(-1)') do set week=%%i
echo %week%
* Output
Saturday
echo %week%
* Output
Saturday
#현재일자 출력 포맷 변경시
for /f %%i in ('powershell ^(get-date -uFormat %y%m%d^).AddDay(-1)') do set date=%%i
echo %date%
* Output
191001
echo %date%
* Output
191001
댓글 없음:
댓글 쓰기