'de dize ile seçilen dosyaların özel adlarını içeren bir tablo oluşturun png, jpg ve bmp ile başlayan dosya adlarıyla 3 liste oluşturmak istiyorum. Tüm dosyalar dizini ağacın içinde görüntülerdir:/year_month/year_month_day/Burada görebileceğiniz gibi:MATLAB
./20160203/20160203_png01_test1.png.tmp
./20160203/20160203_jpg01_test2.jpg.tmp
./20160203/20160203_bmp01_test3.bmp.tmp
./20160204/20160204_png01_test1.png.tmp
./20160204/20160204_jpg01_test2.jpg.tmp
./20160204/20160204_bmp01_test3.bmp.tmp
./20160205/20160205_png01_test1.png.tmp
./20160205/20160205_jpg01_test2.jpg.tmp
./20160205/20160205_bmp01_test3.bmp.tmp
örnek Liste1 her uzantı (jpg, bmp ve png) için resimler adını içermelidir her liste olmalıdır:
./20160203/20160203_png01_test1.png.tmp
./20160204/20160204_png01_test1.png.tmp
./20160205/20160205_png01_test1.png.tmp
list2 olmalıdır:
./20160203/20160203_jpg01_test2.jpg.tmp
./20160204/20160204_jpg01_test2.jpg.tmp
./20160205/20160205_jpg01_test2.jpg.tmp
ve list3 aynı ama bmp ile ... böyle
kodum görünüm:
workdir = '/home/user/201602/';
cd(workdir);
command = ['find -name *test*.tmp'];
[status,cmdout] = system(command);
c = strsplit(strtrim(cmdout));
n_files = length(c);
format_id = cell(n_files,1);
for ifile =1:n_files
d = textscan(c{ifile},'%s%s', 'Delimiter','_');
s1 = d{2}{:};
format_id{ifile} = s1;
end
format_id = unique(format_id);
nformat = length(format_id);
for iformat = 1:nformat
templist = [format_id{iformat} '.dat'];
fid = fopen(templist,'w');
for ifiles =1:n_files
fprintf(fid, '%6s\n', c{iformat});
end
fid = fclose(fid);
end
Ben listelerini almak: png01.dat, jpg01.dat ve ince olan bmp01.dat ama her listedeki resimlerin tüm isimlerine ve sadece ilgili uzantıya sahip isimlere sahip değilim. İlk önce sadece ilgili uzantıya (bmp jpg ve png) sahip dosyaları seçmek için bir "indeks" yapmak ve daha sonra bunları bir listeye göndermek istiyorum. Bunu nasıl yapabilirim?
Umarım sorun açıktır. Yardımlarınız için şimdiden teşekkür ederiz. şöyle
boyunca ek yeni çizgileri kaldırın Sorunuzun böylece daha kolay okunur görünüyor. Bir başka öneri olarak: [ 'dir'] görebilirsiniz (http://ch.mathworks.com/help/matlab/ref/dir.html) -komut 'system' değiştirmek için kullanılır. – Matt