Page 1 of 1

For Each Folder

Posted: Tue Feb 16, 2016 11:31 am
by jlee1

I'm trying to create a project to determine how many files are in each folder. I have a folder with around 50 sub folders that contain files. Is there a way for me to loop through each folder and count the files in each folder? I can't seem to create a list of folders.


Re: For Each Folder

Posted: Thu Feb 18, 2016 9:09 am
by Support_Rick
There are several ways you can accomplish this:

Creating a File list (createFileList) will allow you to point to the root folder, then add a Recursive view. This will traverse all folders (below the root) and return a list of files. An optional variable is the Number of files found. This will give you the TOTAL number of files (in all folders).

To separate by sub-folder, you would have to loop through (forEach) the FileList variable and check for a change in the file attribute "parentFile" (This is the current folder of each file as you loop through.) Create a counter and then you would have the number of files in each folder.

Another way is to use a Folder List. This is detailed with a Forum Post Here.

Creating your folder list would allow you to loop through that rowset of Folder Names, then do a CreatFileList inside each folder to generate the number of files in each.

There are other options as well ... these are just a couple.