how do i display all audio files in subfolder in matlab in matlab

You can use the dir function in MATLAB to list all files within a directory, including all subdirectories. Then, you can loop through the output of dir and detect which files have an audio file extension (e.g. .wav, .mp3, etc.).

Here's an example code that displays all the audio files in subdirectory:

main.m
% set the path to the directory containing the subfolder
path_to_parent_folder = 'path/to/parent/folder';

% get a list of all items (files and folders) in the directory
items = dir(path_to_parent_folder);

% loop through each item in the directory
for i = 1:length(items)
    % get the current item
    item = items(i);
    
    % check if the current item is a directory and isn't the current or parent directory
    if item.isdir && ~strcmp(item.name, '.') && ~strcmp(item.name, '..')
        % get a list of all items (files and folders) in the subdirectory
        sub_items = dir(fullfile(path_to_parent_folder, item.name));
        
        % loop through each item in the subdirectory
        for j = 1:length(sub_items)
            % get the current sub_item
            sub_item = sub_items(j);
            
            % check if the current sub_item is an audio file
            if ~sub_item.isdir && contains(sub_item.name, {'.wav', '.mp3', '.aac', '.flac'})
                % display the name of the audio file
                fprintf('%s\n', sub_item.name);
            end
        end
    end
end
1113 chars
30 lines

Replace path/to/parent/folder with the directory path containing the subfolder. The code only searches for files with extensions .wav, .mp3, .aac, and .flac. You can add or remove file types as needed.

gistlibby LogSnag