As the title suggested does anyone know of a powershell script or any other way of getting the count of how many files are within a folder and its subfolders within a library?
I have tried to look but nothing comes close to what I need to do. Any help would be appreciated.
I have this for 2013. Make sure you edit “out-file C:\Reports\SpFileExport.csv” to where you want the csv to be generated. The script should count the items files and folders for a specified library. and displays it in the powershell window. The CSV that is generated is every file and it’s size and folder location.
$fileCount = 0
$folderCount = 0
$itemcount = 0
$Web = Read-host “Please enter the SPWEB Url”
$WebObject = get-spweb -Identity $Web
$WebObject.Lists | Select Title
$Library = Read-Host “Please enter the Library or list name”
$LibraryObject = $WebObject.Lists[“$Library”]
$itemcount = $LibraryObject.ItemCount
foreach ($folders in $LibraryObject.Folders)
{
$folder = $folders.Folder
$folderCount ++
foreach ($file in $folder.Files)
{
$fileCount ++
$filesizeinkb = ($file.length/1024)
“{0}`t{1}`t{2}” -f $folder.Name, $file.Name, $filesizeinkb | out-file C:\Reports\SpFileExport.csv -Append
}
}
Write-Host -ForegroundColor Green “Total Item Count ” $itemcount
Write-Host -ForegroundColor Green “Total File Count ” $fileCount
Write-Host -ForegroundColor Green “Total Folder Count ” $folderCount
$WebObject.Dispose()
The version is 2010.
That’s true. The issue I ran into was that there are between 15-25 subfolders within 8-10 folders.
Doing it that way would take some time:(
SharePoint 2010 thru SPOnline – If you just want totals, then you could just modify the list/library view to display a count above a column of your choice.