I want to iterate over different file names. The file names are XY1.txt, XY2.txt...XY500.txt. Each file that is taken as input generates 3 output files which I want to rename according to the current index. For XY1.txt, output1.txt becomes 1_1.txt, output2.txt becomes 1_2.txt and so on. But I do not know how to change the filename as per index. I looked it up but I was not finding what I needed on this website or elsewhere. I am new to bash. The below pseudo code is what I was able to write until now. Please help me out
for i in {1..500} ;
filename = "XY"+str(i) + ".txt" ;
do ./CompiledCodeFile -filename -use_option 4;
mv output1.txt str(i)+"_1.txt" ;
mv output2.txt str(i)+"_2.txt" ;
mv output3.txt str(i)+"_3.txt" ;
done