How To Find Total Number of Documents In one SharePoint Online folder

seb seb 36 Reputation points
2022-03-24T10:11:26.24+00:00

Hello,

I'm looking for a way to get the total number of files in a single directory of a sharepoint library (with more than 5000 items).

can you help me ?

thanks

seb

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} vote

Accepted answer
  1. Paul de Jong 806 Reputation points
    2022-04-01T10:46:59.15+00:00

    @seb seb
    An alternative is to use tools that can handle LVT. For example, Explorer. It will make successive requests and show the results in a Windows Explorer like way in your browser. (Use the trial version)

    189020-lvt.png

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Echo Du_MSFT 17,316 Reputation points
    2022-03-25T09:46:19.91+00:00

    Hi @seb seb ,

    Welcome to Q&A Forum!

    Please run the below PowerShell script as an admin to get counts of files:

    #Config Variables  
    $SiteURL = "https://domain.sharepoint.com/sites/sitename"  
    $ListName ="libraryname"  
    #Any file under the given path  
    $FolderServerRelativePath = "/sites/sitename/libraryname/foldername*" #Any file under the given path  
         
    #Connect to PnP Online  
    Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)  
        
    #Get all files from folder  
    $Files = Get-PnPListItem -List $ListName | Where {$_.FieldValues.FileRef -like $FolderServerRelativePath -and $_.FileSystemObjectType -eq "File" }   
      
    Write-Host "File Counts:" $Files.Count  
    

    186827-a.jpg

    186797-b.jpg

    Thanks,
    Echo Du

    ====================================

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. seb seb 36 Reputation points
    2022-03-25T10:21:17.193+00:00

    Thanks but i have this message :

    "Get-PnPListItem: The attempted operation is prohibited because it exceeds the threshold
    list display."

    thanks,
    seb

    1 person found this answer helpful.

  3. Tarana Aghabayova 1 Reputation point
    2022-03-25T10:28:23.073+00:00

    This is a quick note to let you know that we are performing research on this issue.

    0 comments No comments

  4. Mark Singh 1 Reputation point
    2022-06-16T20:10:36.907+00:00

    Sync / add a shortcut to File Explorer. Then use file explore to right click, and see the count of all folders and files in the hierarchy. Kind of a pretty big oversight that you can't do this in SharePoint. You can only go to doc settings and see a full file count, but not a folder count.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.