staged_root = 'C:\Documents and Settings\aih\My Documents\post_doc\SectorAnalysisToolbox\SectorAnalysisProjects\SAP_AG_Project\Staged';
staged_left = [staged_root, filesep, 'Left'];
staged_right = [staged_root, filesep, 'Right'];
if ~exist(staged_left, 'dir')
    mkdir(staged_left);
end
if ~exist(staged_right, 'dir')
    mkdir(staged_right);
end
stages = dir('Level*');
stages = {stages.name};
for i=1:length(stages)
    if ~exist([staged_left, filesep, stages{i}], 'dir')
        mkdir([staged_left, filesep, stages{i}]);
    end
    if ~exist([staged_right, filesep, stages{i}], 'dir')
        mkdir([staged_right, filesep, stages{i}]);
    end
end
break
D = pwd;
for s =1:length(stages)
    files = dir([stages{s}, filesep, '*sectors.tif']);
    files = {files.name};
    for f = 1:length(files)
        file = files{f};
        file = file(1:end-12);
        if ~exist([D, filesep, stages{s}, filesep, file], 'dir')
            mkdir([D, filesep, stages{s}, filesep, file]);
        end
        tomove = dir([stages{s}, filesep, file, '*']);
        tomove = {tomove.name};
        for m=1:length(tomove)
            if ~isdir([stages{s}, filesep, tomove{m}])
                [STATUS,MESSAGE,MESSAGEID] = movefile([stages{s}, filesep, tomove{m}],[stages{s}, filesep, file, filesep, tomove{m}]);
            end
        end
    end
stages{s}
end