close all
clear all

path = 'X:\707976 EPBuoyPrototypeAndTesting\Deployments\Nov2012 Deployment\134.89.12.189\data\R00001\';
results_path = 'X:\707976 EPBuoyPrototypeAndTesting\Deployments\Nov2012 Deployment\DecodedResults\'

while(1)

  files = dir([path 'D*']);
  
  for i = 1:length(files)
    filename = files(i).name
  
    decoded_files = dir([results_path filename '.mat']);
    
    if(length(decoded_files) > 0)
      if(decoded_files.datenum < files(i).datenum)
        SurfaceLogFileDecoderRing(path,filename,results_path)
      end
    end
  
%   idx = zeros(1,length(files));
%   for i = 1:length(files)
%     if(strfind(files(i).name,'.mat'))
%       idx(i) = i;
%       idx(i-1) = i;  %This is a kludge, relies of file ordering to keep from re-decoding a file that already has a .mat file
%     end
%   end
% 
%   for i = 1:length(files)
% 
%     if(~idx(i))
%       filename = files(i).name
%       SurfaceLogFileDecoderRing(path,filename,results_path)
%     end
%   end   
  
  pause(10*60)

end