You have a few possible solutions:
$ ./script *g.log >output
... and hope that
*g.log doesn't expand to something that makes the command line too long. This is not very robust.
If your script doesn't depend on the number of files given to it, i.e., if output can just be appended to
output for each input file, then this is another solution:
$ find ./ -type f -name "*g.log" | xargs ./script >output
A third solution would be to move the loop into the script itself:
for f in *g.log; do
# old code using "$f" as file name
This does not have the problem with command line length restriction since it's in a script.
The invocation of the script would now be
$ ./script >output