The simplest possible script is to create a file with 1 line per command you want to execute.
3dROIstats -1DRformat -quiet -mask directory1/inputfile1 > outputfile1.1D
3dROIstats -1DRformat -quiet -mask directory2/inputfile2 > outputfile2.1D
and so on -- create the first line, copy it, and then edit it into the format you need. If you are good with an editor and if your filenames have some usable pattern, this is usually not very difficult. It can be helped by making a list of all the input files, and then editing that into the script, as in
ls directory*/inputfile* > script.csh
and then edit file script.csh to add the necessary text around the input filenames.
If you do not understand this posting and how to start doing this, then I'm afraid you will have to seek help elsewhere, and perhaps find a course that can teach you scripting.