Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Recursive List of Files or Directories
;This UDF is sort of like the FileItemPath function in that it returns a ;tab delimited list of files. ; This function returns a tab delimited list of files in a directory tree. ; Parameters ; tree - always initialize to "" ; dir - directroy to start in ; mask - file mask to search for, like "*.*" "*.exe" "*.txt" etc ; no directory info allows in the mask ; currentlevel - initialize to zero ; maxlevel - controls how many levels deep you wish to go. TO ; go all the way down set to a large number like 9999 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #DefineFunction FileItemRecursive(tree,dir,mask,currentlevel,maxlevel) ;DebugTrace(@ON,"xxxdebug.txt") If currentlevel>=maxlevel Then Return(tree) currentlevel=currentlevel+1 DirChange(dir) dlist=ItemSort(DirItemize("*.*"),@TAB) dcount=ItemCount(dlist,@TAB) For xx=1 To dcount thisdir=ItemExtract(xx,dlist,@TAB) tree=FileItemRecursive(tree,thisdir,mask,currentlevel,maxlevel) Next If tree=="" Then tt="" Else tt=@TAB flist=FileItemPath(mask) If flist != "" flist=ItemSort(flist,@TAB) tree=StrCat(tree,tt,flist) EndIf DirChange("..") Return(tree) #EndFunction startdir="c:\bizdocs\incoming\" curlevel=0 maxlevel=5 mask="*.*" mytree=FileItemRecursive("",startdir,mask,curlevel,maxlevel) ;show it AskItemlist("Da Files",mytree,@TAB,@UNSORTED,@SINGLE)
;This UDF is sort of like the DirItemize function in that it returns a ;tab delimited list of directories. ; This function returns a tab delimited list of directories in a directory tree. ; Parameters ; tree - always initialize to "" ; dir - directroy to start in ; mask - file mask to search for, almost ALWAYS "*.*" !!!!!!!!!!!!!!! ; no directory info allow in the mask ; currentlevel - initialize to zero ; maxlevel - controls how many levels deep you wish to go. TO ; go all the way down set to a large number like 9999 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #DefineFunction DirItemRecursive(tree,dir,mask,currentlevel,maxlevel) ;DebugTrace(@ON,"xxxdebug.txt") If currentlevel>=maxlevel Then Return(tree) currentlevel=currentlevel+1 DirChange(dir) If tree=="" Then tree=DirGet() Else tree=StrCat(tree,@TAB,DirGet()) dlist=ItemSort(DirItemize("*.*"),@TAB) dcount=ItemCount(dlist,@TAB) For xx=1 To dcount thisdir=ItemExtract(xx,dlist,@TAB) tree=DirItemRecursive(tree,thisdir,mask,currentlevel,maxlevel) Next DirChange("..") Return(tree) #EndFunction startdir="c:\bizdocs\" curlevel=0 maxlevel=9999 mask="*.*" mytree=DirItemRecursive("",startdir,mask,curlevel,maxlevel) ;show it AskItemlist("Da Directories",mytree,@TAB,@UNSORTED,@SINGLE)
Article ID: W15754
File Created: 2003:05:28:10:24:38
Last Updated: 2003:05:28:10:24:38