function matchingFiles = gatherFiles(testFiles, struct,direc_type)
    % Combine all directories provided in varargin with 'Archive' added
    dirFields = fieldnames(struct);
    dirs = cellfun(@(field) fullfile(struct.(field), direc_type), dirFields, 'UniformOutput', false);

    % Initialize fileList to store all files
    fileList = [];

    % Loop through directories
    for k = 1:length(dirs)
        currentDirectory = dirs{k};
        
        % Get a list of all files in the current directory
        files = dir(fullfile(currentDirectory, '*.*'));
        
        % Append the files to the overall list
        fileList = [fileList; files];
    end

    % Create a cell array to store the full file paths
    fullPaths = arrayfun(@(x) fullfile(x.folder, x.name), fileList, 'UniformOutput', false);

    matchingFiles = cell(1, length(testFiles));

    % Loop through the file paths and find the ones that end with the specified file names
    for i = 1:length(fullPaths)
        currentFilePath = fullPaths{i};
        
        for j = 1:length(testFiles)
            currentFileName = testFiles{j};
            
            % Check if the current file path ends with the specified file name
            if endsWith(currentFilePath, currentFileName)
                matchingFiles{j} = currentFilePath;
            end
        end
    end
end




