get body of file name by removing directory and extentions from 'fname' [usage] filebody = vb_util_get_file_body(fname) [input] fname : <required> <<string>> target file path [output] filebody : body of filename without extention [note] remove extentions recursively [history] 2006-10-11 (Sako) initial version 2007-06-22 (Sako) replaced fileparts to vb_get_file_parts (for MATLAB7.4.0) Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function filebody = vb_util_get_file_body(fname) 0002 % get body of file name by removing directory and extentions from 'fname' 0003 % [usage] 0004 % filebody = vb_util_get_file_body(fname) 0005 % [input] 0006 % fname : <required> <<string>> target file path 0007 % [output] 0008 % filebody : body of filename without extention 0009 % [note] 0010 % remove extentions recursively 0011 % [history] 0012 % 2006-10-11 (Sako) initial version 0013 % 2007-06-22 (Sako) replaced fileparts to vb_get_file_parts (for MATLAB7.4.0) 0014 % 0015 % Copyright (C) 2011, ATR All Rights Reserved. 0016 % License : New BSD License(see VBMEG_LICENSE.txt) 0017 0018 % --- CHECK ARGUMENTS --- % 0019 if ~exist('fname', 'var') fname = ''; end 0020 [fname] = inner_check_arguments(fname); 0021 0022 % --- MAIN PROCEDURE --------------------------------------------------------- % 0023 % 0024 % [fdir,fbody] = fileparts(fname); 0025 [fdir,fbody] = vb_get_file_parts(fname); 0026 if isempty(strfind(fbody,'.')) 0027 filebody = fbody; 0028 return; 0029 else 0030 filebody = vb_util_get_file_body(fbody); 0031 end 0032 return; 0033 % 0034 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0035 0036 % --- INNER FUNCTIONS -------------------------------------------------------- % 0037 % 0038 function [fname] = inner_check_arguments(fname) 0039 0040 func_ = 'vb_util_get_file_body'; 0041 0042 if length(fname) == 0 0043 error('(%s)fname is a required parameter', func_); 0044 end 0045 % 0046 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0047 %%% END OF FILE %%%