set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
echo hour=%hour%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
echo min=%min%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
echo secs=%secs%
set year=%date:~-4%
echo year=%year%
set month=%date:~4,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
echo month=%month%
set day=%date:~7,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
echo day=%day%
set datetimef=%year%%month%%day%_%hour%%min%%secs%
echo datetimef=%datetimef%
pause
DOS 文件名时间戳的生成
最新推荐文章于 2023-01-10 20:46:14 发布
本文介绍了一个简单的批处理脚本,用于获取并格式化计算机的当前日期和时间,以便于用作文件名或其他标识符。该脚本通过一系列的条件判断和字符串操作确保了日期和时间的各个部分都是两位数格式。


3772

被折叠的 条评论
为什么被折叠?



