matlab 将一堆文件名读到一个文本里面windows版本里
有点坑:
在windows下,这么写,打印时也会把\n当成字符串打印出来
path= strcat('/home/wang/Desktop/trainset/num0/',file(i).name,'\n');
好吧,这是windows下成功的,注意fid=fopen([save_file_name,'result2.txt'],'a');:
file=dir('C:\Users\cong\Desktop\研一实战\项目\图像中时间数字识别\dataset_time_regconition\trainset\num0\'); save_file_name='C:\Users\cong\Desktop\'; for i=3:length(file) path= strcat('C:\Users\cong\Desktop\研一实战\项目\图像中时间数字识别\dataset_time_regconition\trainset\num0\',file(i).name); %save('/home/wang/Desktop/trainsetimage_name'); %save result6.txt -ascii path fid=fopen([save_file_name,'result2.txt'],'a'); fprintf(fid,'%s\n',path);
fclose('all'); end