MATLAB: Renaming multiple subfolders within folder

dicomfoldersfor loophelpmatrix arraymultiplemultiple foldersrename

Hi all,
I have created a folder with 301 subfolders, each of the subfolders containing dicom images.
However I am required to rename each of the subfolders.
They are currently named P_6CMBCF_…….
And I would like to rename them as follows: P_Tomo_6CMBCF_…….
So I need to add _Tomo after the first letter.
How can I do this?
I am quite new to matlab so any help and guidance would be appreciated.
Thanks

Best Answer

Something like this
files = dir('P_6CMBCF_*');
for i=1:numel(files)
filename = files(i).name;
new_filename = [filename(1) '_Tomo' filename(2:end)];
movefile(filename, new_filename);
end