basename strips filename of directory and file extension. bname = basename(filename) Removes everything before the right-most occurrence of the path delimiter PD, and everything after the left-most occurrence of a dot.
0001 % basename strips filename of directory and file extension. 0002 % 0003 % bname = basename(filename) 0004 % Removes everything before the right-most occurrence 0005 % of the path delimiter PD, and everything after the 0006 % left-most occurrence of a dot. 0007 0008 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2008 0009 % by Dirk B. Walther and the California Institute of Technology. 0010 % See the enclosed LICENSE.TXT document for the license agreement. 0011 % More information about this project is available at: 0012 % http://www.saliencytoolbox.net 0013 0014 function bname = basename(filename) 0015 0016 declareGlobal; 0017 0018 slash = find(filename == PD); 0019 if isempty(slash) 0020 left = 1; 0021 else 0022 left = slash(end)+1; 0023 end 0024 0025 dot = find(filename == '.'); 0026 if isempty(dot) 0027 right = length(filename); 0028 else 0029 right = dot(end)-1; 0030 end 0031 0032 if (left > right) 0033 bname = filename(left:end); 0034 else 0035 bname = filename(left:right); 0036 end 0037