tp@0: function Filenameout = EDB1strpend(Filenamein,striptext) tp@0: % EDB1strpend - Removes a specified ending from a filename. tp@0: % First, any extension is removed. tp@0: % tp@0: % Input parameters: tp@0: % Filenemain A text string with the filename tp@0: % stripext A text string with the ending that should tp@0: % be removed. tp@0: % tp@0: % Output parameters: tp@0: % Filenameout A text string with the extension-stripped filename tp@0: % tp@0: % Uses no special functions tp@0: % tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % This file is part of the Edge Diffraction Toolbox by Peter Svensson. tp@0: % tp@0: % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify tp@0: % it under the terms of the GNU General Public License as published by the Free Software tp@0: % Foundation, either version 3 of the License, or (at your option) any later version. tp@0: % tp@0: % The Edge Diffraction Toolbox is distributed in the hope that it will be useful, tp@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS tp@0: % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. tp@0: % tp@0: % You should have received a copy of the GNU General Public License along with the tp@0: % Edge Diffraction Toolbox. If not, see . tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % Peter Svensson (svensson@iet.ntnu.no) 20100812 tp@0: tp@0: [Filepath,Filenameout,temp1] = fileparts(Filenamein); tp@0: tp@0: if ~isempty(Filepath) tp@0: Filenameout = [Filepath,filesep,Filenameout]; tp@0: end tp@0: tp@0: str1 = lower(Filenameout); tp@0: str2 = lower(striptext); tp@0: n1 = length(str1); tp@0: n2 = length(str2); tp@0: if n1 >= n2 tp@0: if str1(n1-n2+1:n1) == str2 tp@0: Filenameout = Filenameout(1:n1-n2); tp@0: end tp@0: end