Count folders and files by date modified

Hi I want to create logic to count below two scenarios…

Path 1 > /B: (count folders by latest date modified)

Path 2 > /B:>patient case number> .NC (count all .NC files within different patient case folder)

the only way to group patient case folder and .nc files are with date modified.

Thank you for the help

Directory.GetDirectories("YourFolderName").Where(Function(x) New FileInfo(x).LastWriteTime.Date = Now.Date).Count

Above will give you the count of the folder with recent modified date…

I didn’t get your second Requirement…Could you please brief with some example?? Thanks…

second que…
lets say i have folder A, withing that folder i have 100 folders for patients. within those 100 patients folders there are .nc files which i want to count by modified dates.

hope you now got the que

So .nc is the extension? like .xlsx or .docx

OR .nc is within the filename itself??

sorry… yes it is file extension

Here you go…

Here is my workflow…

For Each ==> Type Argument = String

Directory.GetDirectories("YourParentFolder").Where(Function(x) New FileInfo(x).LastWriteTime.Date =Now.Date).ToArray

IntCount = Directory.getfiles(EachFolder).where(function(y) path.GetExtension(y).Contains(".xlsx")).Count

Here IntCount is Int32 varaible

 IntFinalCount = IntFinalCount+IntCount

Here IntFinaCount is Int32 varaible

In this example I am looking for .xlsx files and I got the count of 13(manually verified). Feels free to changed based on your requirement.

Idea is: Get the folder with date modified equals today. And then loop these folders and look for the file extension and increment the count.

Hope this helps…

can you share the .xaml if you dont mind pls

@pmistry - please find the xaml
FileCounts.xaml (7.6 KB)

thank you really appreciate

1 Like

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