Having trouble running multiple files through a batch file from the button bar.

English support forum

Moderators: Stefan2, white, Hacker

Post Reply
lawson415
Junior Member
Junior Member
Posts: 8
Joined: 2004-06-06, 21:56 UTC

Having trouble running multiple files through a batch file from the button bar.

Post by *lawson415 »

I have a compiled matlab script that uses matlab runtime and runs from the command line. I run it in this batch file that supplies the file name for the EEG file to analyze. "MiniQReport.exe %1 EC 27"

This batch file runs from a button in the button bar with the batch file as the command and %S as the parameter.

I select one file or many files and click the and it only processes the first file and then cmd window closes and the process stops. It takes about 90 seconds to process each file. Then the window closes.

I don't know if running only one file and then stopping is related to the way the matlab runtime works.

Any ideas on how I could run all the files with one click? I'm only going to do this job once and I could click and run each file separately. I have about 70 files to run so I can do it one-at-a-time in less than 2 hours but running them all at once would be a lot more fun. I would also have less chance for error.
User avatar
petermad
Power Member
Power Member
Posts: 12311
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *petermad »

I don't know if running only one file and then stopping is related to the way the matlab runtime works.
Why dont you try it from command line with two filenames to see if both files are processed.

Also is "MiniQReport.exe %1 EC 27" the total content of the batch file?
License #524 (1994)
Danish Total Commander Translator
TC 10.52 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.4.1.1022 (x64)
TC 3.41 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Gral
Power Member
Power Member
Posts: 1124
Joined: 2005-01-26, 15:12 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *Gral »

While %S send all filenames %1 only gets the first one.
miskox
Member
Member
Posts: 162
Joined: 2003-06-11, 06:00 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *miskox »

As Petermad and Gral wrote: try it from the command prompt first to see what works for you. Maybe you should run it like this:

Code: Select all

MiniQReport.exe "filename1 filename2" EC 27
But the problem here would be if filename contains spaces.

Maybe there is a help or something for this MiniQReport.exe?

Saso
#224551
Fla$her
Power Member
Power Member
Posts: 771
Joined: 2020-01-18, 04:03 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *Fla$her »

2lawson415
Run minimized
Command: ComSpec% /q/c for %f in
Parameters: ("%S") do start "" MiniQReport.exe %%f EC 27
User avatar
petermad
Power Member
Power Member
Posts: 12311
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *petermad »

I was thinking some similar buttons:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\ ((echo DO NOT MARK DIRECTORIES!) & (echo.) & pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do start "" MiniQReport.exe "%%n"  EC 27
%COMMANDER_EXE%,2
Open all selected files with MiniQReport.exe at the same time


-1
or

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\ ((echo DO NOT MARK DIRECTORIES!) & (echo.) & pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do call MiniQReport.exe "%%n"  EC 27
%COMMANDER_EXE%,2
Open all selected files with MiniQReport.exe one after another


-1
To make the buttons:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".
It might be necessary with a path to MiniQReport.exe

These should work with unicode names (not on Windows XP)
License #524 (1994)
Danish Total Commander Translator
TC 10.52 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.4.1.1022 (x64)
TC 3.41 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
miskox
Member
Member
Posts: 162
Joined: 2003-06-11, 06:00 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *miskox »

Note to this command:

Code: Select all

do start "" MiniQReport.exe "%%n"
I would suggest you add

Code: Select all

/wait
after the START command so each file is processed one at a time.

Saso
#224551
User avatar
nsp
Power Member
Power Member
Posts: 1732
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *nsp »

You can also use TCBL if you do not have to process Unicode Filename.

Code: Select all

pgm:<path to>\tcbl.exe
params:-qe %L MiniQReport.exe "$f" EC 27
e option is to have the resulting batch file opened with notepad before starting it.
Fla$her
Power Member
Power Member
Posts: 771
Joined: 2020-01-18, 04:03 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *Fla$her »

miskox wrote: 2022-11-29, 09:08 UTCI would suggest you add

Code: Select all

/wait
There would be no point in "start" then. And asynchronous launch was proposed based on this:
lawson415 wrote: 2022-11-28, 19:49 UTCbut running them all at once would be a lot more fun.
lawson415
Junior Member
Junior Member
Posts: 8
Joined: 2004-06-06, 21:56 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *lawson415 »

Thank you MadPeter

I used the second button suggestion and it worked perfectly. I have about 80 files to run and they each take 50-70 seconds. I suspect this 2 core i5 machine would choke on doing them all at once so I chose the sequential option.
petermad wrote: 2022-11-28, 23:10 UTC I was thinking some similar buttons:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\ ((echo DO NOT MARK DIRECTORIES!) & (echo.) & pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do start "" MiniQReport.exe "%%n"  EC 27
%COMMANDER_EXE%,2
Open all selected files with MiniQReport.exe at the same time


-1
or

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\ ((echo DO NOT MARK DIRECTORIES!) & (echo.) & pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do call MiniQReport.exe "%%n"  EC 27
%COMMANDER_EXE%,2
Open all selected files with MiniQReport.exe one after another


-1
To make the buttons:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".
It might be necessary with a path to MiniQReport.exe

These should work with unicode names (not on Windows XP)
lawson415
Junior Member
Junior Member
Posts: 8
Joined: 2004-06-06, 21:56 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *lawson415 »

Thank you everyone,

I'm grateful to each of you for your suggestions. I chose MadPeter's second suggestion because it looked easiest and because there was an option for sequential processing. As a single EEG analysis takes about a minute on this 2 core i5 and I have 70- to 80 files, I was afraid it would choke on that many files.

I will try the simultaneous solution on another computer and report back.

Gratefully,
Robert Lawson
lawson415
Junior Member
Junior Member
Posts: 8
Joined: 2004-06-06, 21:56 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *lawson415 »

Oops, Petermad,

I apologize for getting your name wrong. Mad Peter is funnier but not appropriate.

I tried using the first script that you posted above that analyzes the files simultaneously. I selected 74 files and clicked on the icon and a many terminals opened up very quickly. The script processed about 12 files and then a bunch of folders with long numerical names. That these folders appeared after the last of the 12 files was processed. It also made many failed reports of 0kb size.
User avatar
petermad
Power Member
Power Member
Posts: 12311
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *petermad »

2lawson415
I originally made the two buttons for notepad.exe, and I have never tried with more than about 10 files opening at the same time.

I guess that 74 instances of the same program can choke most computers.
License #524 (1994)
Danish Total Commander Translator
TC 10.52 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.4.1.1022 (x64)
TC 3.41 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
lawson415
Junior Member
Junior Member
Posts: 8
Joined: 2004-06-06, 21:56 UTC

Re: Having trouble running multiple files through a batch file from the button bar.

Post by *lawson415 »

Thank you for the recent help.

We used that batch file with a lot of archival data for testing.

Now we want to do a validity test and use real data and ages.
We will need to add another argument to this batch file to run from a button and then enter 2 arguments from a file.

Old batch file: "MiniQReport.exe %1 EC 27"
This file says run MiniQReport.exe to analyze this EEG file name and compare the data to normative data for eyes closed condition using the norms for a 27 year old.

Here is the new batch file:
"MiniQReport.exe %1 EC %2"

The first argument is file name and the second is age.

We would like to enter these arguments from a text file. I think we used to do something like this with list2multi.

The file might be like this:

filename 4
filename 16
filename 63

How might we do this keeping our long file names?
Post Reply