I want to get a count of files in a directory which I could get very easy with adir() however there could be more than 65,000 files on occasion and this will crash Fox as it will exceed the maximum array size.
Tesar, I do like your idea as it is very fast - and added two lines to it which will make the
file tdir showing only files-names, as all subdirectories and size-infos are NOT written
using the first two letters in capital letters:
! dir > tdir.txt
crea table tdir(text C(40))
appe from tdir.txt type sdf
****************************
*and now:
****************************
delete all for ! isupper(substr(text,1,2))
pack
****************************
*tdir should show file-names only.
This is another approach which I tested with 700 files (used 0.3 seconds) please try
and let me know whether you had problems with more than 65.000 files and how
the performance was.
Regards from Germany
Klaus
*filecount.prg
*This program shows how many files are in a directory
*and makes a string-variable (myfilenumber) of it.
*should work for more than 65,000 files as infos
*are stored in a memo-field.
starttime = SECONDS()
CLOSE DATA
CREATE TABLE filecount (mymemo m)
APPEND BLANK
LIST FILES LIKE *.* TO myfiles.txt
APPEND MEMO mymemo FROM myfiles.txt OVERWRITE
CLEA
&& comment:
&& myfilenumber is a text-string where in
&& relation to the language the
&& number of files can be seen
&& or extracted from.
&& "eg: xxxxx byte in yyy files"
&& where yyy is your file-counter requested.
This is slightly off your topic, but are you aware that having that many files in one directory is a huge performance hit on most operating systems (in fact more that 2000 tends to be an issue). This was definatly true in NT4, Win98 and earlier. I have not tested it in 2000 or xp
The directory is an archive directory on a dual xeon Windows 2k server. Seperate NTFS 15,000 RPM HDD than the HDD with the db file server on it. We keep track of the directory for the client to warn them when it hits 100,000 files, any more than that and it takes ages to backup to tape.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.