function token = cut(str,n)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: Cut the nth token from str.  Convert it to a number. Assume tokens
% are delimited by white space.
% AUTHOR:  Rob McEwen
% DATE:    00/6/1
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
 mpath     = pwd;
 remainder = mpath;
 
 while (~isempty(remainder))
   [token,remainder]=strtok(remainder,'/');
 end
 dirname = token;
 return;