Reputation: 11
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.
Upvotes: 0
Views: 77
Reputation: 41234
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"
Upvotes: 1