str2path.pro
443 Bytes
FUNCTION str2path,str
IF STRPOS(str, '\') GE 0 THEN sep = '\' ELSE sep = '/' ; simple WINDOWS test (GV 2013-09-09)
;vv=strsplit(str,'/',/extract)
;path=''
;FOR i=0L,n_elements(vv)-2 DO path=path+'/'+vv(i)
;path=path+'/'
vv=strsplit(str,sep,/extract)
path=''
FOR i=0L,n_elements(vv)-2 DO path=path+sep+vv(i)
path=path+sep
IF STRPOS(path, '\') GE 0 THEN path = STRMID(path,1) ; remove first '\' for WINDOWS (GV 2013-09-09)
RETURN,path
END