|Thanks for the "for" method! I finally understood how it works, and it does work. |
Except for one thing which is just absurd.
The file.sql > "%%a" part interprets as:
file.sql 1> file.dat
There is a "1" before the ">" symbol. I figured it might be because my file was a .cmd instead of .bat (I read the latter required %% instead of % for defined variables). I renamed it to .bat and there still is a "1" before the > symbol.
I tried escaping it with a ^ sign, and it worked.
So the final version would be:
for /r %%a in (file.dat) do"%CD%\sqlite3.exe" file.sql ^> "%%a"
Also, I removed the if exists "%%a" part because it cannot NOT exist in my case (also, it didn't work for some reason).
Thank you so, so much!