function Directory = SetDirectory()
% Determine System
dlm = system();

% Fine all .csv files 
A = dir('**/*.csv');
B = {A.name}';
% Filter to just get the file names and directories of the _log files. 
Log = contains(B,"_log");
Folder = {A.folder}';
LogFolder = Folder(Log);
LogFile = B(Log);

% For each log file set the directory and the target file location to the
% correct working directory
for i = 1:length(LogFolder)
    Folder = string(LogFolder(i));
    File = string(LogFile(i));
    File1 = append(Folder, dlm, File);
    Tbl = readtable(File1);
    Dir = Tbl.Directory;
    Tbl.Directory = append(string(pwd),dlm);
    Tgt = string(erase(Tbl.TargetCurve,[Dir Tbl.OutputFile '\', '/']));
    Tbl.TargetCurve = append(string(pwd),dlm, string(Tbl.OutputFile),dlm,Tgt);
    
% Write the table out.
    writetable(Tbl,File1,"WriteVariableNames",true);

end

% function to determine operating system.
        function dlm = system()
            warning('off','all')
            if ismac
                % Code to run on Mac plaform
                dlm = '/';
            elseif isunix
                % Code to run on Linux plaform
            elseif ispc
                dlm = '\';
            else
                uialert(app.UIFigure,'Error 23: Platform not supported','Error 23')
            end
        end
end