How to get image files from subdirectories with in a directory?
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
In matlab i want to access all the images of the extension ".hdr" from subdirectories which in turn are in a directory. And consequently all the image-names must be returned in a cell with one row and many columns, depending upon the number of images.I already used 'getAllFile' but I couldn't get the desired results. Please help me with any other idea. Thank you :-)
0 comentarios
Respuestas (1)
  Roberto
      
 el 7 de Mayo de 2014
        
      Editada: Roberto
      
 el 7 de Mayo de 2014
  
      to get the files from a folder try this:
   selDossier = uigetdir;  % ask for the folder
    searchedExtension = '.hdr' ;
    cd(selDossier); % go to the folder
    currentFile = dir ; % read folder's content
    selectedFile = {} ;
    for i = 1:numel(currentFile) % look for files
        if ~currentFile(i).isdir % discard subfolders
            if strcmpi(currentFile(i).name(end-4:end),searchedExtension) 
                selectedFile{end+1} = currentFile(i).name ; %filename
            end
        end
    end
of curse you can create a recursive function that returns all files while there's a subfolder in current folder!, that's some extra code you must write!
0 comentarios
Ver también
Categorías
				Más información sobre Low-Level File I/O en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

