*! 8jun2011 program collectpaths version 11.1 syntax anything(everything), [fn(string) fpaths(string) fnames(string) fexts(string) os] foreach bit in fn fpaths fnames fexts { if mi("``bit''") local `bit' `bit' } mata: DoIt() c_local `fn' `fnback' if (`fnback'==1) { c_local fpaths1 `fpathsback1' c_local fnames1 `fpathsback2' c_local fexts1 `fpathsback3' } else { forval f=1/`fnback' { c_local `fpaths'`f' `fpathsback`f'1' c_local `fnames'`f' `fpathsback`f'2' c_local `fexts'`f' `fpathsback`f'3' } } end version 11.1 mata: void DoIt() { parts=columnize(st_local("anything"),";") files=J(0,1,"") for (p=1;p<=length(parts);p++) files=files\multipath(parts[p],".dta") files=pathparts(uniqrows(files)) if (st_local("os")=="") files[,1]=subinstr(files[,1],dirsep(),"/") st_local("fnback",strofreal(rows(files))) tostata("fpathsback",files) } end