windows下用時間戳創建文件名
阿新 • • 發佈:2017-12-12
str sym start ebs mbo tracker tail class mysql\
英文環境下:
echo Archive_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.zip
中文:
- echo 根據當前日期時間,生成文件名稱,......
- set YYYYmmdd=%date:~0,4%%date:~5,2%%date:~8,2%
- set hhmiss=%time:~0,2%%time:~3,2%%time:~6,2%
- set "filename=WebSite3copy%YYYYmmdd%_%hhmiss%.zip"
- echo %filename%
去掉空格的方式:
- c:\>set h=%time:~0,2%
- c:\>set h=%h: =0%
- c:\>echo %date:~0,4%%date:~5,2%%date:~8,2%%h%%time:~3,2%%time:~6,2%
- 20150324090254
參考的鏈接: http://blog.csdn.net/chinadm123/article/details/44588891
http://blog.csdn.net/xuexiaodong009/article/details/53462592
https://stackoverflow.com/questions/7727114/batch-command-date-and-time-in-file-name
我的備份mantis的腳本:
cd C:\Program Files\MySQL\MySQL Server 5.6\bin
set h=%time:~0,2%
set h=%h: =0%
set "filename=Mantis_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.sql"
echo %filename%
mysqldump -uroot -p3edc$RFV bugtracker > \\172.16.10.240\Infa_Shared\Mantis\%filename%
windows下用時間戳創建文件名