spm_fileparts.m 713 B

123456789101112131415161718192021222324
  1. function [pth,nam,ext,num] = spm_fileparts(fname)
  2. % Like fileparts, but separates off a comma separated list at the end
  3. % FORMAT [pth,nam,ext,num] = spm_fileparts(fname)
  4. % fname - original filename
  5. %
  6. % pth - path
  7. % nam - filename
  8. % ext - extension
  9. % num - comma separated list of values
  10. %__________________________________________________________________________
  11. % Copyright (C) 2005-2011 Wellcome Trust Centre for Neuroimaging
  12. % John Ashburner
  13. % $Id: spm_fileparts.m 4439 2011-08-25 17:47:07Z guillaume $
  14. num = '';
  15. if ~ispc, fname = strrep(fname,'\',filesep); end
  16. [pth,nam,ext] = fileparts(fname);
  17. ind = find(ext==',');
  18. if ~isempty(ind)
  19. num = ext(ind(1):end);
  20. ext = ext(1:(ind(1)-1));
  21. end