How to get the files count inside the folders?

Can anyone just tell me the exact code how can i get the files count present inside the folder’s
there are zip files inside the folder’s i want the count of that files and once i got the count i want to paste that count under column name of the folder’s
how can i do this?

Hi @Priyesh_Shetty1

FileInfo[ ]zipFiles = directory.GetFiles(“*.zip”); // Retrieves all ZIP files in the folder

int zipFileCount = zipFiles.Length; // Gets the count of ZIP files

image

Hope it helps!!

@Priyesh_Shetty1

  1. Use the “Assign” activity to assign the folder path to a variable. Let’s say the variable is named folderPath.
  2. Use the “Directory.GetFiles” method to get a list of all files in the folder. Pass folderPath as the input. This will give you an array of file paths.
  3. filter the file paths and keep only the ones that have the “.zip” extension. Set the input array to the array of file paths obtained in the previous step.

folderPath = folderPath.AsEnumerable().Where(Function(a) a.ToString.Contains("zip”)).ToArray

  1. Use the “Assign” activity to assign the count of zip files to a variable. Let’s say the variable is named zipFileCount. Set its value to zipFilesArray.Count.
  2. Use the “Write Cell” activity to write the value of zipFileCount to the desired column in your folder’s spreadsheet or Excel file. Specify the cell address where you want to write the count, such as “A1” or “B2”.
1 Like

@raja.arslankhan


I want ouput like this as mentioned in above image.

But the folder’ name that is KARVY,BSE,DOTEX,CVLKRA,CAMS these folders name are not there daily sometime there are only 2 folders sometime only one.

@raja.arslankhan there is no activity like filter array?

@Priyesh_Shetty1
Oh output that you need is little bit tricky.
Yes I updated the post

@raja.arslankhan



These are the folder and files inside the folder’s are like this

So basically user want the count of pan no’s and total count of Pan’s.

User also want the


pan number’s to be pasted as i have uploaded the above image.

How can i perform this?

@raja.arslankhan i didnt got the point 3rd?

@Priyesh_Shetty1 point 3 will return only zip files

@raja.arslankhan what does the 4th point means i didnt get it…the value zipfilesarray?