In a batch file, I want to run an executable that is located in another folder, and use it on files in my current folder.
I can accomplish this by running
C:\directory\example\executable.exe --exampleparam examplefile, but what I want to know if it's possible to do this if
C:\directory\example is unknown and stored in a variable.
@set folder=C:\directory\example %folder%\executable.exe --exampleparam examplefile
I couldn't get it to work like this, and wording this use case is a little weird and didn't find much relevant to it.
Here's my full code. It imports the content of 40-something MS Access databases, each contained in their own folder, into a MySQL database using this program's command line.
@set settingsfolder="C:\Users\me\Documents\import" @set mysqlfolder="C:\Program Files (x86)\DevDesktop\mysql\bin" @set msa2mysfolder="C:\Program Files (x86)\Bullzip\MS Access to MySQL" @set mdbfolder="C:\Users\me\Documents\dumps" SETLOCAL ENABLEDELAYEDEXPANSION @for /D %%f in (%mdbfolder%\*) do @( @set fname=%%~nf @set databaseid=!fname:~0,2! @set settings=%settingsfolder%\settings.ini @type NUL > !settings! @echo [MoveDB MSAccess to MySQL] >> !settings! @set importdirectory=%mdbfolder%\!fname!\db\database.mdb @IF EXIST !importdirectory! @( @echo sourcefilename=!importdirectory! >> !settings! @IF !databaseid! == 001 ( type %settingsfolder%\db_init.ini >> !settings! ) ELSE ( type %settingsfolder%\db_append.ini >> !settings! ) echo Importing !databaseid!... %msa2mysfolder%\msa2mys settings=!settings!, autorun %mysqlfolder%\mysql --user=root -e "set @dbid=!databaseid!;UPDATE data.table1 SET db_id = @dbid WHERE db_id IS NULL;UPDATE data.table2 SET db_id = @dbid WHERE db_id IS NULL;" echo !databaseid! finished ) )
The error I'm getting on each iteration is "Unknown database: \mysql"
It works fine if I use the quoted paths instead of variables.