function [f] = setBackslash(theDir,action) % setBackslash takes care fo the last character in a directory name % action = 'set': the last character will be a \ % = 'remove': a possible backslash is removed if iscell(theDir) f=theDir{1,:}; else f=theDir; end if strcmpi(action,'set') if ~strcmpi(f(length(f)),'\') f=[f '\']; end else strcmpi(action,'remove') if strcmpi(f(length(f)),'\') f=f(1:length(f)-1); end end end