0

I'm trying to run a mysqldump with a date filename

mysqldump -umyuser -pmypass mydatabase > c:\backup\%DATE%.sql

Problem is, filename is printing as 6/17/12.sql. Is there a way to change the separator characters when it tries to write the file?

1 Answer 1

3

Your system's date format may be set differently than mine (I have "Mon " prefixing my 6/17/13), but you should be able to do a replace on a new variable for date like so

set datefix=%DATE%
set datefix=%DATE:/=-%

The colon lets it know you're doing a replace, and it sets all "/" to "-" (pick whatever char you want, but remember some have to be escaped).

Output:

Mon 06-17-2013.txt

Edit: So your batch would be three lines; the two above, then your line looking like this:

mysqldump -umyuser -pmypass mydatabase > c:\backup\%datefix%.sql

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .