PDA

View Full Version : InstallScript Help - Traversing directory tree and getting file list gives duplicates



ravnstorm
08-03-2017, 03:07 PM
I'm trying to get the size of a large folder - 17.1 GB. The folder has 53 subfolders and 386 files. To begin with, I'm trying to traverse the directory tree and get the file sizes of each of the files. Currently, I'm just writing the information to a file for troubleshooting. The problem is that it is going back and traversing some folders again, and I can't figure out why!!! The results should show that there are 53 folders and 386 files. Instead it gets 53 folders and 1057 files. Can anyone see what is wrong with the FindAllFiles loop in the script attached?

ravnstorm
08-03-2017, 04:31 PM
I think I found the answer. Some of the subfolders are parent folders, that don't have files, but they have more subfolders. I was able to get the right list of files by first gathering a list of only directories that had actual files in them. It's dumb, but adding the attached changes worked. (Attachment doesn't include the variable declarations, etc)

MarkusLatz
08-05-2017, 04:24 AM
Here is another sample:

Get Size of All Files in a Directory:

http://www.installsite.org/files/GetDirFileSize.zip

from this site:

http://www.installsite.org/pages/en/isp_comp.htm

regards

Markus

ravnstorm
08-08-2017, 11:22 AM
Thank you for checking into this and replying.