天天看點

matlab建立檔案夾與批量移動檔案到單一檔案夾或者各自檔案夾

代碼備份自用的,可參考movefile 函數

clear  
clc  
cd('C:\EO');%設定目前目錄:current directory   
 for i = 1 : 47 
     folderName{i} = ['sub_', num2str(i)];  
     mkdir(folderName{i});  % 建立一個檔案夾   
end 
 eval(['load ',prefix_common,'_ec_fft_stsp_sub_',num2str(i,'%03d'),'.mat;']);

a='C:\EO';
b='C:\EO';

for k = 24:47
%     b=num2str(k,'%3d');
%     a=[sourcePath,'\','N_EC_1_Sub_',num2str(k,'%03d'),'.nii'];
    targetPath=[a,'\','sub_',num2str(k,'%01d')];
    sourcePath=[b,'\','N_EO_Sub_',num2str(k+1,'%03d'),'.nii'];
    movefile(sourcePath,targetPath);
end
           

繼續閱讀