MATLAB: How to put a struct files into a new folder

folderstruct

Hi guys,
After i use the following code to find files i want, how to put those files into the new folder? Thank you.
This code will give me the info of files in a struct such as name, path, size etc.
files = dir('D:\Data\**\*.mat')

Best Answer

destdir = 'D:\Data\MDA\MDA Matlab\Area';
files = dir('D:\Data\MDA\MDA*\cell*_Area.csv');
fullnames = fullfile({files.folder}, {files.name});
if ~exist(destdir, 'dir')
mkdir(destdir);
end
copyfile(fullnames, destdir); %or movefile() if appropriate