I have a directory tree with different files in it, and i would like to execute a .bat file for each of these file that is ending with ".sct", no matter where in the directory tree the file is.
I already tried to do this selecting all files in the search results and using the "Start" menu, but when i use the "%P%S" argument in the parameter field, TC only passes the path of one single file to the .bat file, instead of all selected files.
Am I missing something, or could this be a bug?
Cheers!
Executing a .bat file for each file in the search result.
Moderators: white, Hacker, petermad, Stefan2
Re: Executing a .bat file for each file in the search result
Check your batch file.gerthmar wrote:I have a directory tree with different files in it, and i would like to execute a .bat file for each of these file that is ending with ".sct", no matter where in the directory tree the file is.
I already tried to do this selecting all files in the search results and using the "Start" menu, but when i use the "%P%S" argument in the parameter field, TC only passes the path of one single file to the .bat file, instead of all selected files.
Am I missing something, or could this be a bug?
Cheers!
This works perfectly and there is no bug in this function of TC
Re: Executing a .bat file for each file in the search result
if you use %P%S you will get a long list of all selected file on a single line. The bat file you specify will be called only once.gerthmar wrote:I have a directory tree with different files in it, and i would like to execute a .bat file for each of these file that is ending with ".sct", no matter where in the directory tree the file is.
I already tried to do this selecting all files in the search results and using the "Start" menu, but when i use the "%P%S" argument in the parameter field, TC only passes the path of one single file to the .bat file, instead of all selected files.
Am I missing something, or could this be a bug?
Cheers!
If you want to call a bat file multiple time having the selected file as parameter passed one by one, you need to use an intermediate batch, tools or modify your current bat to accept more than one parameter.
Another solution is to use TCBL or other wrapper.
Code: Select all
@echo off
rem Processing of %P%S
:loop_next
if -%1==- goto loop_end
echo Do something with "%~1"
shift
goto loop_next
:loop_end
pause
Code: Select all
@echo off
rem Processing of %L or %WL
for /f "usebackq delims=" %%s in (`type %1`) do echo Do something with "%%s"
pause