it's the first time that I write a little script in batch, I need to create a folder named like the date, then I want to go in that directory and run the dump of my database. Here my code:
cd C:\Users\Administrator\Documents\db_backup
FOR /f "tokens=2-4 delims=/ " %%a in ('date /t') do mkdir %%a-%%b-%%c
cd C:\Program Files\MySQL\MySQL Server 5.6\bin
mysqldump -uroot -proot emc > C:\Users\Administrator\Documents\db_backup\*here goes the folder created before*\backup.sql
I know that probably is a stupid question, but i never work whith batch. Thanks to everybody.
The date format changes by region settings and machine - it's wiser to use Wmic to get it in a stable format.
But this should work:
cd /d "C:\Users\Administrator\Documents\db_backup"
FOR /f "tokens=2-4 delims=/ " %%a in ('date /t') do set d=%%a-%%b-%%c
md "%d%"
cd /d "C:\Program Files\MySQL\MySQL Server 5.6\bin"
mysqldump -uroot -proot emc > "C:\Users\Administrator\Documents\db_backup\%d%\backup.sql"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.