Get files count from each available folder's and paste it under column of a folder name

Can anyone tell me how can i get the count’s of the file’s from each folder’s and i want the total count also.

let say there are 4 folder’s so basically i want the count of files which is present in the folder’s and i want the total count’s also.

And this count’s i want to paste it in the excel with column name of the folder’s?

Hi @Priyesh_Shetty1

1.Assign the folder paths into an variable “Folderpaths” of type string[ ]
2.Initialize a int32 variables “cnt” and “Rcount”

The output will give the count of files present in the folder.

Hope it helps!!

@pravallikapaluri it is giving wrong count it is giving only one folder count properly.

it should take count of each folder’s

@Priyesh_Shetty1
Try with this
Move the assign activity cnt to inside of the loop

Hope it helps!!

@pravallikapaluri this 2nd code is giving right output know i want the total files of all folder
what should i do for that?

@Priyesh_Shetty1

The First Output will gives all the total number of files Present in all the folders.It is showing the correct output i.e,Older file Count+ newest filecount= messagebox …

Hope You got the answer!!

I want to paste the ouput like this and i have to mail this to client.

How can i do this?

Hi @Priyesh_Shetty1

You have to use HTML for sending Excel Tables along with Email Body. It will surely work.

Thanks.

@pratik.pandya can you just tell me the steps?

@pratik.pandya or a code how can i do this i want to paste all the counts under the columns and total counts also.

@Priyesh_Shetty1

I Don’t know about the Exact code but you have to add Each Column and Rows one by one using loop into the HTML Code which is present inside the variable.

Read Range from Excel into a datatable.
Add Data Column “File Count” as Int32
For Each Row in Datatable

  • Assign CurrentRow(“File Count”) = Directory.GetFiles(CurrentRow(“folderPath”).ToString).Count

//end for each
Write Range back to Excel.

To get the total:

yourDT.AsEnumerable.Sum(Function(a) Convert.ToDouble(a(“FolderCount”).ToString))

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