Search code examples
windowsbatch-filecmdcommandquotes

mysqldump space in directory with variable


I have a batch file that mysqlpdump into a directory share folder that has a space in the dir name.

@echo off
set datefix=%DATE%
set datefix=%DATE:/=-%

mysqldump -u -p mydb > C:\Weird Dir\backup\%datefix%.sql
exit

Creates this error:

mysqldump: Couldn't find table: "Dir\backup\06-25-13.sql"

I've tried googling for the syntax of using a directory name but can't find anything. Tried setting full path as variable and then including and concat the string but it gives me a syntax error.


Solution

  • mysqldump -u -p mydb > "C:\Weird Dir\backup\%datefix%.sql"
    

    put the whole path in double quotes.