Help with running a script on files located in subdirectories

Hello everyone,

I'm am a newbie to coding so I am reaching out in hopes that I can get some help from this forum.

I am trying to run the script below from a single directory, however the directory has many subfolders. In each of those subfolders is a file, uniquely named to that specific subfolder, that ends in a specific extension.

I want to run the script below so that it will go into each subfolder and find the file that ends with .ecclog and run the contents of the script on it and then continue on to the next subfolder until it's gone through all of them.

Now, I don't know what to change in the script file itself, if anything and how to write a new script so that it will run recursively and loop through.

I have 160 of these subfolders so going through them one by one is very tedious.

If anyone can help me with those tasks, it will be a HUGE help!

..edited

Did you consider the find command? Using it like

find . -name "*.ecclog"

would list all those files in all subdirs that you're after.

Okay, so find will find the .ecclog files in all the subdirectories but how do I run the mentioned script on all those .ecclog files? Do I need to change/delete anything in the script as well? (I think it has a ls command in there)

I don't really understand the script. Without any context (how the script is run, what it's about, parameter values, constraints, boundary conditions) I'm afraid I'm out of ideas.