function createFileList(rootdir, rundir, cntr)
%CREATEFILELIST   Extracts the most recent files from the rundir to a rootdir based on an automatically generated file list
%

% -------------------------------------------------------------
% Copyright (c) WL|Delft Hydraulics 2004-2007 FOR INTERNAL USE ONLY
% Version:      Version 1.0, February 2007 (Version 1.0, February 2007)
% By:           <M. van Koningsveld (email: mark.vankoningsveld@wldelft.nl>
% -------------------------------------------------------------

clc

if nargin == 0
    rootdir = 'P:\ucit\McTools\Demo McTools';
    rundir  = 'P:\ucit\McTools\Demo';
end

fid=fopen([rundir filesep 'demo' num2str(cntr) '.txt'],'w');
fclose(fid);

cd(rootdir)
fns=dir;
fns=fns(3:end);
for i=1:length(fns)
    cd(rootdir)
    if fns(i).isdir==1
        disp(fns(i).name)
        if strcmp(fns(i).name,'UCIT')
            xx=0
        end
        stepOneDown(fns(i),[rootdir filesep fns(i).name],rundir,'',cntr)
    else
        disp(fns(i).name)
        writeFile(rootdir,fns(i),rundir,cntr)
    end
end

