Aug 03, 2017 03:07 PM
InstallScript Help - Traversing directory tree and getting file list gives duplicates
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?
Aug 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)