Having trouble scripting the search function with PSD files

Hello,

I am working on a script to bulk process PSD files. When I use the line of code below and run the script, the sFiles come up empty despite having results in the GUI. How can I edit the script to process on the PSD files?

sFiles = bst_process('CallProcess', 'process_select_search', [], [], ...
    'search', '(([type EQUALS "Spectrum"] ))');

Since all PSD files are Time-frequency files, you can search them like this:

% Process: Select timefreq files in: */*/psd
sFiles = bst_process('CallProcess', 'process_select_files_timefreq', sFiles, [], ...
    'subjectname',   SubjectNames{1}, ...
    'condition',     '', ...
    'tag',           'psd', ...
    'includebad',    0, ...
    'includeintra',  0, ...
    'includecommon', 0, ...
    'outprocesstab', 'process1');  % Process1

Thank you!

Additionally, I am using the script below to extract PSD frequency bands, and I am having trouble getting them to save in one total CSV file rather than one CSV file per PSD file. Do you have any advice on how I could go about adding that to this script?

for iFile = 1 : length(sFiles)
    sBandFiles = [];

    for iFreqBand = 1 : size(FreqBands, 1)
        % Process: Extract values: [all] 2-4Hz
        sFileBand = bst_process('CallProcess', 'process_extract_values', sFiles(iFile), [], ...
            'timewindow', [], ...
            'freqrange',  str2num(FreqBands{iFreqBand, 2}), ...
            'rows',       '', ...
            'isabs',      0, ...
            'avgtime',    0, ...
            'avgrow',     0, ...
            'avgfreq',    0, ...
            'matchrows',  0, ...
            'dim',        1, ...  % Concatenate signals (dimension 1)
            'Comment',    '');

        % Process: Add tag: delta
        sFileBand = bst_process('CallProcess', 'process_add_tag', sFileBand, [], ...
            'tag',            FreqBands{iFreqBand, 1}, ...
            'output',         'name_path');  % Add to file name and file path

        % Concatenate band files
        sBandFiles = [sBandFiles, sFileBand];
    end

    % Process: Export to file: Timefreq
    bst_process('CallProcess', 'process_export_file', sBandFiles, [], ...
        'exporttimefreq', {ExportDir, 'ASCII-CSV-HDR'});

    % Process: Delete selected files
    bst_process('CallProcess', 'process_delete', sBandFiles, [], ...
        'target', 1);  % Delete selected files
end