Question

I have a batch file and it doesn't work. The funny thing is all the commands work while running inside of the cmd window.

The NON-WORKING - FAULTY line from batch file:

    for /F %%i in ('dir /B C:\Users\Jacek2\Desktop\USB\test\1\depesza*') do (
move /Y C:\Users\Jacek2\Desktop\USB\test\1\"%%i" C:\Users\Jacek2\Desktop\USB\test\1\depesza.cvs && start /wait E:\EasyPHP-12.0\mysql\bin\mysqlimport.exe --columns=typ_raportu,kod_stacji --user=root --password= --host=127.0.0.1 --fields-enclosed-by="\"" --fields-terminated-by="," --fields-escaped-by="" test C:\Users\Jacek2\Desktop\USB\test\1\depesza.csv)

From CMD window:

    c:\>for /F %i in ('dir /B C:\Users\Jacek2\Desktop\USB\test\1\depesza*') do move
/Y C:\Users\Jacek2\Desktop\USB\test\1\"%i" C:\Users\Jacek2\Desktop\USB\test\1\de
pesza.cvs && start /wait E:\EasyPHP-12.0\mysql\bin\mysqlimport.exe --columns=typ
_raportu,kod_stacji --user=root --password= --host=127.0.0.1 --fields-enclosed-b
y="\"" --fields-terminated-by="," --fields-escaped-by="" test C:\Users\Jacek2\De
sktop\USB\test\1\depesza.cvs

The batch file works when I remove the code below from my batch file.

&& start /wait E:\EasyPHP-12.0\mysql\bin\mysqlimport.exe --columns=typ_raportu,kod_stacji --user=root --password= --host=127.0.0.1 --fields-enclosed-by="\"" --fields-terminated-by="," --fields-escaped-by="" test C:\Users\Jacek2\Desktop\USB\test\1\depesza.csv)

Does anyone know why?

Was it helpful?

Solution

Try this. If it's not a cmd length issue then the double quotes further along are being taken as a window title. The leading "" stop that issue.

start "" and the rest of your command

OTHER TIPS

I'd suggest escaping each of the & with ^

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top