close all
clear all

dpath = '134.89.12.189/data/';

%while(1)
  dataDirs = dir([dpath 'R*']);

  for k = 1:length(dataDirs)
      if(dataDirs(k).isdir == 1)
          ppath = [dpath dataDirs(k).name '/'];
          disp(['Processing Data Directory ' ppath]);
          
          files = dir([ppath 'D*']);
          
          for i = 1:length(files)
             if(isempty(strfind(files(i).name,'.mat')))  %Not a .mat file
             
             %Check to see if a newer .mat version exists
             checkfiles = dir([ppath files(i).name '.mat');
             if(length(checkfiles == 0)  
                 
                 
             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))
              display(['Decoding ' files(i).name]);
              %SurfaceLogFileDecoderRing(ppath,files(i).name);
            end
          end    
          
      end
  end
      
%MakePlots
  
%pause(10*60);

%end