question

JasonLevy-9876 avatar image
0 Votes"
JasonLevy-9876 asked ·

Creating Mass Sharepoint Subfolders In One Go

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

office-sharepoint-onlineoffice-sharepoint-server-administration
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JasonLevy-9876 ,

Is there any update? If my answer is helpful to you, you could accept it as answer.

0 Votes 0 ·

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered ·

Hello @JasonLevy-9876 ,

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.

· 2 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I assume the same applies for sharepoint online?

sorry realised I should have mentioned its online and not on prem

so if online then connect-spotennant first and then run the script?

0 Votes 0 ·

Hello @JasonLevy-9876 ,

Yes, it applies for sharepoint online.

You do not need to connect-spotennant first, just run the script would work for you. It is pnp powershell, so Connect-PnPOnline -Url $siteURL would be ok. You could have a try.

0 Votes 0 ·