@echo off set "dirname=%date:~,4%%date:~5,2%%date:~8,2%" ::通过 %date% 系统变量得到日期为"2013/05/22 周三",%date:~,4% 表示取日期的前面4个字符就是年份 ::%date:~5,2% 表示取日期第5个字符开始的2个字符就是月份,%date:~8,2% 这个就是日期。 set "path=D:\db" set "mysqldump="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe"" set "backuser=root" set "backpass=root" ::echo %dirname% ::echo %path% ::echo %mysqldump% ::echo %path%%dirname% if not exist %path%\%dirname% mkdir %path%\%dirname% %mysqldump% --opt -u%backuser% -p%backpass% mysql > %path%\%dirname%\mysql.sql ::echo "Successfully" exit
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/1762.html