0

I am trying to create a bat file which read all the files of a directory and for every file runs descr_tool.exe. I ve found the following command which do so, for the same directory with the bat file:

echo off 
  for /r %%a in (*) do echo %%a >> get_files.txt start    
  D:\christos\SelfSimilarity\Release\descr_tool.exe 0   
  "D:\christos\ExtractCEDD\img\animal_2.jpg"  10 codebook1.txt
pause

How can I run proper the exe file from my .bat. The values after exe is my three arguments.

EDIT: The exe file it works. But I dont know how to put arguments proper to work normally.


Ok I think, it worked without the start before the exe file. Now I want to do two things: first to replace path+image with %%a and output.txt with imagefilename.txt.

echo off 
  for /r %%a in (*) do (
   echo %%a >> get_files.txt 
   "D:\christos\SelfSimilarity\Release\descr_tool.exe" 0 "%%a"  10 "%%a".txt
   echo hello
  )
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Jose Ramon
  • 5,572
  • 25
  • 76
  • 152

2 Answers2

1

I think you're almost there. Just add brackets.

Try this:

echo off 
for /r %%a in (*) do (
  echo %%a >> get_files.txt 
  "D:\christos\SelfSimilarity\Release\descr_tool.exe" 0 "D:\christos\ExtractCEDD\img\animal_2.jpg"  10 codebook1.txt

)
pause
David
  • 853
  • 8
  • 24
1

To add in the same directory as the original file, try

"D:\christos\SelfSimilarity\Release\descr_tool.exe" 0 "%%a"  10 "%%~dpna".txt

If you want all of the reports in a "reports" directory,

"D:\christos\SelfSimilarity\Release\descr_tool.exe" 0 "%%a"  10 "d:\your\reports\directory\%%~na".txt

See for /? from the prompt for options.

%%~da yields the Drive %%~pa yields the Path %%~na yields the Name %%~xa yields the eXtension

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • THanks magoo, finally I found how to store files in different paths. How about avoiding the message press any key to continue.. message? – Jose Ramon Feb 27 '14 at 12:31
  • I know nothing of the `descr_tool` application. If it is this that is generating that message, try `ECHO.| ` before the `"D:\christos....` ; that is, `ECHO.| "D:\christos....` . This *should* mean the executable receives an automatic ENTER. If you want to suppress the message itself, try appending `>nul` after the end of the command, `...~na".txt >nul` – Magoo Feb 27 '14 at 12:48
  • Basically, indeed I had a forgotten system("pause") in main file of descr_tool. :( – Jose Ramon Feb 27 '14 at 12:57