Create folder in SharePoint Online document library
Folders are used to organize files in SharePoint, similar to what we do in our computer. You can add a folder to SharePoint online list or library by following below steps.
How to Create a folder in SharePoint Online?
To create a folder in SharePoint online, Follow these steps:
How to Enable the "New Folder" option?
What if the New Folder option is grayed out? If the New Folder button isn't available, you can enable it.
SharePoint Online: Create Folder using PowerShell-CSOM:
Lets create folder in SharePoint document library using PowerShell.
Create Sub-Folder at given path using PowerShell:
We can add a folder or sub-folder to any existing library or folder using PowerShell.
Folders are used to organize files in SharePoint, similar to what we do in our computer. You can add a folder to SharePoint online list or library by following below steps.
How to Create a folder in SharePoint Online?
To create a folder in SharePoint online, Follow these steps:
- Login to your SharePoint online site, Navigate to your document library in which you want to create a folder.
- On the ribbon, click on Files tab (Items tab, if its a list, instead of library)
- Click New Folder
- In the Create A New Folder window, enter the folder name and click Save!
How to Enable the "New Folder" option?
What if the New Folder option is grayed out? If the New Folder button isn't available, you can enable it.
- Navigate to the List or Library setting >> click Advanced settings.
- In the Folder section, Click "Yes" option to Make "New Folder" option available.
- Click OK to save your changes.
SharePoint Online: Create Folder using PowerShell-CSOM:
Lets create folder in SharePoint document library using PowerShell.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
##Variables for Processing
$SiteUrl = "https://crescent.sharepoint.com/"
$ListName="Shared Documents"
$FolderName="Reports"
$UserName="salaudeen@crescent.com"
$Password ="Password Goes here"
#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
Try {
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials
#Get the List Root Folder
$ParentFolder=$Context.web.GetFolderByServerRelativeUrl($ListName)
#Create New Folder
$Folder = $ParentFolder.Folders.Add($FolderName)
$ParentFolder.Context.Load($Folder)
$ParentFolder.Context.ExecuteQuery()
Write-host "New Folder Created Successfully!" -ForegroundColor Green
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Create Sub-Folder at given path using PowerShell:
We can add a folder or sub-folder to any existing library or folder using PowerShell.
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials
#Create New Sub-Folder
$Folder=$Context.Web.Folders.Add("Shared Documents/Reports/V2")
$Context.Load($Folder)
$Context.ExecuteQuery()
Write-host "Folder Created at: " $Folder.ServerRelativeUrl -ForegroundColor Green