%
% PURPOSE:  Run processRadarGarmin.m, cycling through a directory.
% DATE:     21 June 2022
% MODS:     Rob McEwen, intial.


dataFileName = 'atSeaDataFiles.txt';

if( 2~=exist(dataFileName) )
  fprintf('Please create a text file similarly:\n')
  fprintf('ls -l atSea_1655[7-8]* > %s.\n',dataFileName)
else

  fprintf('File %s found.\n',dataFileName)

  
  FILE = fopen(dataFileName);

  str = 'start';
  cntr = 1;

  tic;
  
  while(ischar(str) && cntr < 1000)
    str = fgetl(FILE);
    %
    % Skip commented lines:
    ptr = regexp(str,'^[ ]*%');
    if(ptr)
      continue;
    end
    indx = strfind(str,'atSea');
    %
    % Skip any lines that don't contain a file name:
    if(isempty(indx)) 
      continue; 
    end
    fileName = str(indx:end-1);      %The -1 removes the trailing star.
    fprintf('Processing file %d, %s now.\n',...
        cntr, fileName );

    %                          plotLevel, saveFigs, existAhrs, automatic 
    processRadarGarmin(fileName, 1,          1,         1,      'autoG')
    
    cntr = cntr + 1;
  end

  toc;
  fprintf('''Run'' is finished and has examined %d files.\n',cntr);

end
  
