-1

I am studying how to build batch files

Building a batch file to run exe files sequentially

I just read and try to understand how to run exe files sequentially .

However, I am not really sure how to run all the exe files in the subfoler.

for example, I just copied package folder from USB drive( location can be any where) and package folder has subfolder call drivers ( for example , /package/drivers)

and I would like to run exe files sequentially from batch files in the main folder.

how batch file realizes currently folder and then executes all the exe files in the subfolder ?

thanks

Community
  • 1
  • 1
Bob Ma
  • 197
  • 5
  • 11
  • 22
  • 1
    Is this a Windows issue or a Unix issue? You say `exe` and `batch-file`, but you also have `bash` and `sh` selected. What OS is this for? Do you have a PC with BASH on it? – David W. Nov 14 '13 at 20:27

2 Answers2

2

In bash/sh you can use a for loop:

for file in /package/drivers/*.exe
do
    "$file"
done
that other guy
  • 116,971
  • 11
  • 170
  • 194
1
find /package/drivers/ -name \*.exe -print0 | xargs -0 -n1 sh -c
ArtemB
  • 3,496
  • 17
  • 18