clear; clc;

file_list = dir;
folder_idx = find([file_list(:).isdir]);
folder_idx = folder_idx(3 : end);
data_pool = [];

for i = 1 : length(folder_idx)
    
    curr_folder_idx = folder_idx(i);
    next_folder = file_list(curr_folder_idx).name;
    cd(next_folder);
    
    disp(['Now ', next_folder]);
    
    f_list = dir;
    f_list_names = {f_list(:).name};
    empty_mask = cellfun(@isempty, strfind(f_list_names, '.txt'));
    filtered_file_name = f_list_names(~empty_mask);
    
    for j = 1 : length(filtered_file_name)
       num = importdata(filtered_file_name{j});
       data_pool = [data_pool; num];
    end
    
    disp(['Leaving ', next_folder]);
    cd('..');
end
data_pool
