1.

Solve : Running executables with arguments?

Answer»

Hi there,

I am trying to create a batch file that reads all FILES from a specific folder (ie. input) and processing these files and outputing the results in the output folder.

for example this is my file structure

process
input
output
transform

so BASICALLY, my batch file and my executable resides in the process folder. all my files that NEEDS to be processed are kept in process\input and the files that have been processed by the executable are stored in process\output. the process is kept in process\transform.

the executable file that takes in 3 argument, 1st argument is the output filename, 2nd arg is the process file, 3rd arg is input file. my batch file looks like this

for %%x in (.\input\*.xml) do (
echo processing %xx
transform.exe -o .\output\trans%xx %xx .\xslt\this.xsl
)

for some REASON, i am getting a runtime error and the reason for that is the output to dos from my 3rd line goes like this
transform -o .\output\transxx .\xslt\this.xsl

it doesnt seem to recognize the 2nd argument and it is missing in the output.

could someone kindly point out where i am goin wrong here?

cheersSorry folks,

I did realise my mistake, i should have used %%x instead of %xx. its a typo error on my part and a waste 2hours of my time trying to figure out what is wrong.

anyway, i still have a problem. the value returned in the set (.\input\*.xml) is including the path as well. How can i tweak it so that it only returns the filename when I access %%x?

Assuming my filename in the input folder is input.xml and my process is process.xslt, the batch file returns

transform -o .\output\.\input\input.xml .\input\input.xml .\xslt\process.xsl

as you can see the path for the output file is wrong, hence i just need the filename instead of the WHOLE value in the set.

thanksIt's always helpful to mention your OS in this section as each version of the shell program is different. This may work on some machines:

Code: [Select]for /f %%x in ('dir /b .\input\*.xml') do (
echo processing %%x
transform.exe -o .\output\trans%%x %%x .\xslt\this.xsl
)

8-)

Thanks a lot mate. that worked.



Discussion

No Comment Found