Creating Mass Sharepoint Subfolders In One Go

Jason Levy 106 Reputation points
2021-03-08T01:41:19.403+00:00

Hi there,

We have a alot of client folders in our Sharepoint Document Library that will require us to input a 2021 folder within them, instead of doing this manually for each one (over 100) is there a script that can be run or some better way of doing it?

Thx

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. MichaelHan-MSFT 18,126 Reputation points
    2021-03-08T06:30:15.86+00:00

    Hello @Jason Levy ,

    You could use PnP powershell to achieve this, below is my example script for your reference:

    $siteURL="https://tenant.sharepoint.com/sites/test"  
    $library="/Shared Documents"  
    Connect-PnPOnline -Url $siteURL  
      
    $folderColl=Get-PnPFolderItem -FolderSiteRelativeUrl $library -ItemType Folder  
    foreach($folder in $folderColl){  
    	$folderUrl=$library+"/"+$folder.name  
    	Add-PnPFolder -Name "2021" -Folder $folderUrl  
    }  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.


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.