两个文件夹
samplePath = '.\result\ImageTest17';
dataPath = '.\source\ImageTest17';
fileList = dir(samplePath);
for k = 1:length(fileList)
delete([dataPath,'\',fileList(k).name]);
end
同一个文件夹
clear;
clc;
selpath = uigetdir(path);
UsePicPath =[selpath,'\UsePic'];
if ~exist(UsePicPath,'dir')
mkdir(UsePicPath)
end
strdir = [selpath , '\*.xml'];
namelist =dir(strdir);
len = length(namelist);
for i = 1:len
file_name{i}=namelist(i).name;
source_xml = fullfile(selpath, file_name{i});
destination_xml = fullfile(UsePicPath, file_name{i});
copyfile(source_xml,destination_xml);
source_jpg = strrep(source_xml,'.xml','.jpg');
destination_jpg = strrep(destination_xml,'.xml','.jpg');
copyfile(source_jpg,destination_jpg);
end