Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Get Info from a Pair of Directories GetDirInfoTotals
;Define the function that does all the real work #DefineFunction GetDirInfoTotals(dir) ;Save original directory origdir=DirGet() ;Change to directory to inspect DirChange(dir) ;Display current directory for warm fuzzy feeling BoxText(DirGet()) ;Get total size of files in this directory ;and make sure it is a floating point number ;by adding 0.0 as it can get very large. total=FileSizeEx("*.*")+0.0 totF=ItemCount(FileItemize("*.*"),@tab) ;Get a list of subdirectories in this directory ;and count how many there are. dirlist=DirItemize("*.*") dircount=ItemCount(dirlist,@tab) totD=dircount ;For each subdirectory, call out GetDirSize UDF ;to determin its size. for xx=1 to dircount ;Pick off a subdirectory name thisdir=ItemExtract(xx,dirlist,@tab) ;Add size of that subdirectory to our running total dirData=GetDirInfoTotals(thisdir) total=total+ItemExtract(1,dirdata,@tab) totD=totD+ItemExtract(2,dirdata,@tab) totF=totF+ItemExtract(3,dirdata,@tab) next ;Change back to the directory we entered with DirChange(origdir) ;Return current value of total to caller. return (strcat(total,@tab,totD,@tab,totF)) #EndFunction ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;True start of program lookatdirA="c:\testdir" lookatdirB="c:\testdir" ;Allow system and hidden files to be counted IntControl(5,1,0,0,0) ;Open a Box to display warm fuzzy progress to user BoxOpen("File Size Inspector","Reading Initial Directories") ;Call our UDF to compute info of first dir dirdataA=GetDirInfoTotals(lookatdirA) totsizeA=ItemExtract(1,dirdataA,@tab) totdirsA=ItemExtract(2,dirdataA,@tab) totfilesA=ItemExtract(3,dirdataA,@tab) ; Convert size to to KB totKBA = INT(totsizeA/1024) ;Call our UDF to compute info of second dir dirdataB=GetDirInfoTotals(lookatdirB) totsizeB=ItemExtract(1,dirdataB,@tab) totdirsB=ItemExtract(2,dirdataB,@tab) totfilesB=ItemExtract(3,dirdataB,@tab) ; Convert size to to KB totKBB = INT(totsizeB/1024) ;Display Results text=strcat(lookatdirA," ",totKBA,"KB ",totdirsA,"dirs ",totfilesA,"files",@crlf) text=strcat(text,lookatdirB," ",totKBB,"KB ",totdirsB,"dirs ",totfilesB,"files",@crlf) Message("DirInfo", text) Exit
Article ID: W15514
File Created: 2003:05:13:11:28:28
Last Updated: 2003:05:13:11:28:28