matlab 读多个文件夹(有名字规律)中的文件名字保存到txt中

save_file_name='C:\Users\cong\Desktop\研一实战\项目\图像中时间数字识别\OCR\result6\';
for j=0:1:9
    image_path=strcat('C:\Users\cong\Desktop\研一实战\项目\图像中时间数字识别\trainingSample\num',num2str(j),'\');
    file=dir(image_path);%%%%%%    
    txtname=strcat('result',num2str(j),'.txt');    
    for i=3:length(file)
         path= strcat(image_path,file(i).name);%%%%%%
         fid=fopen([save_file_name,txtname],'a');%%%%%
         fprintf(fid,'%s\n',path);
         fclose('all');
    end    
end

 

posted on 2015-10-24 20:56  一动不动的葱头  阅读(1292)  评论(0编辑  收藏  举报

导航