I tested below is working well on shell. I'd like to update this on spec file. Get filename of all filenames existing inside some folder
for filename in testfolder/*.txt; do
filename =${filename %.txt}
done
All SPEC sections but %files
and preamble are shell scripts. You can use it there without a problem.