WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

DirSize Slow


Question:

I'm trying to resolve a problem with DirSize taking too long to execute. This program I have seems to take a long time to do the DirSize() function. The directory is a large directory. I wonder if there is a better (faster) way to find this information than DirSize()? Does DirSize() take advatage of Windows' built in indexing function...and if I enable volume indexing, would it speed up this function?

Answer:

You mentioned it takes a long time to execute the DirSize() function because the directory is a large. How large exactly?

I recommend first changing the DirSize Flag from 0 to 1. I have found it returns much faster when I use the flag 1, which tells it to return the amount of disk space it occupies. This is based upon the disk's cluster size. This flag is valid only if the specified directory is on a local drive or a network drive mapped to a drive letter; it does not support UNC's.

If any of the directories could be over 2 GIG in size, I recommend using the optional Format parameter to return the data as a huge number instead. Then use the Huge Math Extender function for calculations.

We like to think that the DirSize function is optimized as much possible. The DirSize function uses a very standard set of Windows APIs (FindFirstFile/FindNextFile) to search through the directory structure.

I suppose you could try executing a DOS command to see if that is any faster. If so you could execute the scommand and pipe the data out to a file then parse the results using WinBatch. Also, if you look in the \WinBatch\Samples directory on your machine, you can find a FileSize.wbt file that will search the hard drive accumulating file sizes. You could try modifying that to fit your needs. However I highly doubt it would have faster results than using the DirSize function.

There is no explicit code that takes advantage of Windows' built in indexing functionality, however it is possible that the FindFirstFile/FindNextFile APIs are affected by it.


Article ID:   W16967
File Created: 2007:07:03:14:27:22
Last Updated: 2007:07:03:14:27:22