Macro file for scoring

_Geant4 Version:_v11.1.1
_Operating System:_Ubuntu 22.04.3 LTS
_Compiler/Version:_gcc 11.4.0
_CMake Version:_3.22.1

I want to score the photon flux as a function of energy (to get the energy spectrum) using a macro file. I’d like to have 150 energy filters (from 0 to 150 keV with a step of 1 keV) and i want to make a loop for that.
This is a screenshot of how to do it without a loop, but i need to automate it:

Screenshot from 2023-09-25 12-16-04