% etl met files are on  R: which is /etl//ps3das02/raw
addpath([matlabroot '/work']);
addpath([matlabroot '/work/structures']);
if exist('etl.mat','file')
    load etl.mat
else
    etl=[];
end

% nfn=update_etl_files(etldir);
% fprintf('got %d new files \n',nfn);
% 

newfiles=dir('data/etl/new/met*.txt');
for iiif = 1:length(newfiles),
    fname=newfiles(iiif).name;
    infile=['data/etl/new/' fname];
    fprintf('%d %s  ',iiif, infile);
    %% now get the data from this file
    newetl=get_etl(infile,day1);
    if exist('etl','var') && isstruct(etl)
        etl=structsadd(etl,newetl);
    else
        etl=newetl;
    end
    save etl.mat etl
    load etl.mat
    if ~issorted(etl.mday)
        [mday,edx]=sort(etl.mday);
        structsort(etl, edx);
    end

    try
        movefile ( infile, 'data/etl/read');
    catch
        % always says it can't, but it does move the file
        fprintf('can not move %s to data/read',infile);
    end

end

% % now sort (unique) all the fields
%
% [jjyday,kx,j]=unique(etl.mday); clear j jjyday
%
%
% % keyboard
%
% % [etl_s] = structsort(etl, kx);
% % save etl_sorted.mat etl
% %
% % disp('saved etl_sorted.mat')
%

