I need to read the file count of all the files in all the sub folders in a folder

i need to read the file count of all the files in all the sub folders in a folder , i have written the code as “Directory.GetFiles(“C:\Users\JOBIJOSE\Documents\raw\raw”).COUNT” in the folder i have different folders with pngs , i need to know the count of all pngs in different folder in the main folder “raw”

Hi @JOBIN_JOSE

FolderPath = "C:\Users\JOBIJOSE\Documents\raw\raw"

SearchPattern = "*.png"

FileCount = Directory.GetFiles(folderPath, SearchPattern, SearchOption.AllDirectories).Count

Use a Write Line activity to print the value of the `FileCount` variable to see the total count of ".png" files in all subfolders.

Hope this helps!!

1 Like

Hi @JOBIN_JOSE

Try this:

totalCount = (From folder In Directory.GetDirectories("C:\Users\JOBIJOSE\Documents\raw\raw", "*", SearchOption.AllDirectories)
       From file In Directory.GetFiles(folder, "*.png")
       Select file).Count

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.