Reputation: 470
xxxxWhen i run my DB BAckup file like this:
@echo off
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump" -hlocalhost -uroot -pxxxxx --all-databases > "D:\DB backups\AllDBs_%date%.sql"
it works fine. Bus as soon as I add the %time% placeholder its doesn't work anymore.
@echo off
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump" -hlocalhost -uroot -pxxxxx --all-databases > "D:\DB backups\AllDBs_%date%_%time%.sql"
The filename, directory name, or volume label syntax is incorrect.
Anyone have an idea why this is not working? I've searched the Internet but havn't found anything saying it should not work.
Upvotes: 0
Views: 284
Reputation: 354714
If you want a date and a time you're much better off using the following method:
for /f "skip=1" %%x in ('wmic OS GET LocalDateTime') do if not defined LocalDateTime set LocalDateTime=%%x
set MyDate=%LocalDateTime:~0,8%
set MyTime=%LocalDateTime:~8,6%
This is guaranteed to be in a known format (i.e. just the numbers without any delimiters). And you definitely won't have the problem of invalid characters, regardless of how your locale settings are.
Upvotes: 2
Reputation: 31251
In batch the %time%
variable contains invalid characters for a valid windows filename.
Use this to remove them and replace the invalid chars with -
's.
%DATE:/=-%%TIME::=-%
Upvotes: 0