classes = {'badminton', 'rowing', 'sailing', 'snowboarding'};

input_folder = 'images/';

train_files = cell(0, 0);

selected_idx = cell(length(classes), 1);
num_per_class = 20;

for i=1:length(classes)
    files = arrayfun(@(x) x.name, dir([input_folder classes{i} '/train/*.jpg']), 'UniformOutput', false);
    selected_idx{i} = randsample(length(files), num_per_class) + length(train_files);
    train_files(end+1:end+length(files), 1) = cellfun(@(x) [classes{i} '/train/' x(1:end-4)], files, 'UniformOutput', false);
end

fprintf('train_files = {');
for i=1:length(selected_idx)
    for j=1:length(selected_idx{i})
        fprintf('''%s'', ...\n', train_files{selected_idx{i}(j)});
    end
end
fprintf('};');