1. 程式人生 > >將A檔案中與B檔案同名但不同字尾名的檔案提取出來並扔到C資料夾中 matlab

將A檔案中與B檔案同名但不同字尾名的檔案提取出來並扔到C資料夾中 matlab

fileList = dir('C:\Users\DELL\Desktop\data\helen\train\train_res\*.jpg');
sourcePath = 'C:\Users\DELL\Desktop\helen\helen\trainset\';  
targetPath = 'C:\Users\DELL\Desktop\data\data1\helen\';  

newname = cell(1954,1); 

for k = 1 : length(fileList)  
    newname{k}= fileList(k).name(1:end-4);  %刪掉字尾名,只儲存名字
    copyfile([sourcePath,'\',newname{k},'.pts'],targetPath);   %僅賦值與jpg同名的pts檔案
end