1
votes

Directories

I have a directory which contains many directories, I need to know how I can know the name of directories containing more than 12 files.

Either powershell or batch are fine.

2
You need to better explain your task. It is clear that you have one parent directory containing mutiple child directories. Do you intend to determine the number of files in the top level of each of those children? or the number of files contained within the entire tree of each of those children? Please also explain which questions you found using the search facility at the top of the page under the [batch-file] tag and/or [powershell] tag, using terms like count and files because I'm certain there are many similar already on this site. - Compo
I added a printscreen in the main question. As you can see there is a main folder with many subfolders, I need to know the name of the subfolders which contain more than 12 files - Fabrizio
What you should show us is the code you have tried yourself. Did you even try searching for a solution? - Theo
Nothing in your added image, answers the questions I've asked. All you have just done is create sixteen new directories within a directory named main, and took a screenshot. Please try to read comments and address any questions raised within them. - Compo

2 Answers

1
votes
cd C:\Parent
Get-ChildItem | Where-Object { @(Get-ChildItem $_).count -gt 12} 

  • Get-ChildItem returns a list of all files and folders in the current folder.

  • Where-Object allows us to filter that list, to get only the folders that match the criteria. $_ refers to the current object for each iteration.

This should work.

0
votes

I found the solution in the following link: count of files per directory Thanks for your help.