I need to get the size of all files of a type (say, *.dbf) in a folder.
I can easily write a function that goes thru the file list, but it seems to me there would be an existing function that does it... but i can't find it.
thanks
Simple question (from a simple person)
Simple question (from a simple person)
There are only 10 kinds of people - those who understand binary and those who don't 

Re: Simple question (from a simple person)
Bruce,
From the Alaska docs for function directory()
From the Alaska docs for function directory()
Code: Select all
#include "Directry.ch"
PROCEDURE Main
LOCAL aDbfFiles := Directory("*.DBF")
LOCAL nCount := Len(aDbfFiles)
LOCAL n, nSum
nSum := 0
FOR n:= 1 TO nCount
nSum += aDbfFiles[ n, F_SIZE ]
NEXT
? nCount, "DBF files occupying", nSum, "Bytes"
RETURN
Re: Simple question (from a simple person)
thanks...
i could have done something similar (although not quite as slick). I was hoping there as a function (perhaps something like DirSize(*.dbf) ) that would do it automatically, but I guess not.
i could have done something similar (although not quite as slick). I was hoping there as a function (perhaps something like DirSize(*.dbf) ) that would do it automatically, but I guess not.
There are only 10 kinds of people - those who understand binary and those who don't 

Re: Simple question (from a simple person)
bruce,
simply change the first 2 lines of the code to:
function dirsize(aMask)
LOCAL aDbfFiles := Directory(aMask)
and the lst 2 to:
// ? nCount, "DBF files occupying", nSum, "Bytes"
RETURN(nSum)
and you have it..
dirsize("*.dbf")
simply change the first 2 lines of the code to:
function dirsize(aMask)
LOCAL aDbfFiles := Directory(aMask)
and the lst 2 to:
// ? nCount, "DBF files occupying", nSum, "Bytes"
RETURN(nSum)
and you have it..
dirsize("*.dbf")
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises
Re: Simple question (from a simple person)
That's basically what I did. The aFiles[ n, F_SIZE ] didn't work, so I changed things to:
FUNCTION FileTypeSize(Ftype)
LOCAL aFiles := Directory(Ftype)
LOCAL nCount := Len(aFiles)
LOCAL n, nSum:=0
FOR n:= 1 TO nCount
nSum += aFiles[ n, 2]
NEXT
RETURN nSum
FUNCTION FileTypeSize(Ftype)
LOCAL aFiles := Directory(Ftype)
LOCAL nCount := Len(aFiles)
LOCAL n, nSum:=0
FOR n:= 1 TO nCount
nSum += aFiles[ n, 2]
NEXT
RETURN nSum
There are only 10 kinds of people - those who understand binary and those who don't 
