I have multiple .txt files with names like:
mR1_M1_D1.txt, mR2_M1_D1.txt,....mr100_ M1_D1.txt
mR1_M1_D2.txt, mR2_M1_D2.txt,....mr100_ M1_D2.txt
mR1_M2_D1.txt, mR2_M2_D1.txt,....mr100_ M2_D1.txt
mR1_M2_D2.txt, mR2_M2_D2.txt,....mr100_ M2_D2.txt.
All the files I have mentioned there are in a folder. I would like to group all this files into 4 groups depending on the semifinal and final suffix. the semifinal suffix is M1 and M2 and the final suffix is D1 and D2.
So I want one group with all the files with suffix : M1D1.txt
one group with all the files with suffix : M1D2.txt
one group with all the files with suffix : M2D1.txt
one group with all the files with suffix : M2D2.txt
Notice: These files have 4 columns and 1 line ( I am uploading a format)
could you help me?
I think that I have to modify this script , but I do not know how:
txtFiles = dir("mR*.txt") ;
N = length(txtFiles) ;
A = zeros(N,4) ;
for i = 1:N
a = importdata(txtFiles(i).name) ;
A(i,:) = a ;