Try this...
Get the filenames:
pathname = '\path\to\current\files';
ext = '*.csv';
d = dir(fullfile(pathname,ext));
filenames = {d(:).name}';
Create masks for the groups of files you are interested in using regexp:
mask1 = ~cellfun('isempty',regexp(filenames,'type 3'));
mask2 = ~cellfun('isempty',regexp(filenames,'type 4'));
mask3 = ~mask1 & ~mask2;
Copy (or move) the files from their source location to a new destination using copyfile (or movefile):
src = fullfile(pathname,filenames(mask1));
dest = fullfile('X',filenames(mask1));
cellfun(@copyfile,src,dest);
src = fullfile(pathname,filenames(mask2));
dest = fullfile('Y',filenames(mask2));
cellfun(@copyfile,src,dest);
src = fullfile(pathname,filenames(mask3));
dest = fullfile('Z',filenames(mask3));
cellfun(@copyfile,src,dest);
Best Answer