Yes this is possible, below you can find some pseudo code showing the logic behind the process.
Hope it helps.
EDIT: updated the pseudo code after the comments of the OP
InputFolders = [ "C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\glioma\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\meningioma\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\notumor\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\pituitary\"];
OutputFolders = [ "C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_1\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_2\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_3\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_4\"];
for f = 1:numel(InputFolders)
imagelist = dir( InputFolders(f) );
imdata = cell(1,numel(imagelist));
fname = imagelist(k).name;
sss = InputFolders(f) + string(fname);
curr_image = imread(sss);
processed_image = imagepreprocessing(curr_image);
for o = 1:numel(OutputFolders)
ooo = OutputFolders(o) + string(fname)