function createReports

llDir = fullfile('E:','temp','loadleveler');
dirs = [ dir(fullfile(llDir,'0*')) ; dir(fullfile(llDir,'1*')) ];
dirs = dirs(logical([dirs.isdir]));
[selection,ok] = listdlg('PromptString', ['Select directories to';'create reports for...'], 'ListString', {dirs.name}, 'ListSize',[128 128], 'InitialValue', length(dirs));
if ~ok
    return
end

hWait = waitbar(0,'Please wait...');

%apply selection
dirs = dirs(selection);
%prepare data structure
datedirs   = {};
jobdirlist = {};
numJobs = 0;
for date = {dirs.name}
    datedir   = fullfile(llDir, date{1});
    jobs      = dir(datedir);
    jobs(1:2) = []; % this is '.' and '..'
    jobs      = jobs(logical([jobs.isdir]));
    jobdirs   = {};
    for job = {jobs.name}
        jobdirs{length(jobdirs)+1} = fullfile(datedir,job{1});
        numJobs = numJobs + 1;
    end
    datedirs   {length(datedirs)+1}   = datedir;
    jobdirlist {length(jobdirlist)+1} = jobdirs;
end


% Tasks for each job dir:
% 1. Run epochs.pl
% 2. Run messageAggregates.pl
% 3. graph messages
% 4. graph generations
progressTotal = numJobs * 4 + 1;
progress = 0;

scriptE  = [ 'perl ' fullfile(llDir, 'epochs.pl')            ' ' ];
%scriptMA = [ 'perl ' fullfile(llDir, 'messageAggregates.pl') ' ' ];
scriptMA = [ 'bash ' fullfile(llDir, 'catMsgs.sh') ' ' ];

for indexDate = 1:length(datedirs)
    datedir = datedirs   {indexDate};
    jobdirs = jobdirlist {indexDate};
    for indexJob = 1:length(jobdirs)
        jobdir = jobdirs{indexJob};
        
        progress = progress + 1; waitbar(progress/progressTotal, hWait, ['<' jobdir '>...']);
        dos( [ scriptE jobdir ] );
        progress = progress + 1; waitbar(progress/progressTotal, hWait, ['<' jobdir '>...']);
        dos( [ scriptMA jobdir ] );
        progress = progress + 1; waitbar(progress/progressTotal, hWait, ['<' jobdir '>...']);
        savePrefix = graphMessages(jobdir);
        progress = progress + 1; waitbar(progress/progressTotal, hWait, ['<' jobdir '>...']);
        graphEpochs(jobdir, savePrefix);
    end
end

close(hWait);
end
