I am trying to organise my project folders and I want a way in which I could open a folder and it automatically creates 5 folders each inside named A,B,C,D,E everything.
Can this be done in share point without code or minimal code?
2
Try to Powershell:
Here is the PowerShell code snippet for creating Folders and Sub-Folders inside SharePoint List or Library:
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction:SilentlyContinue))
{
Add-PsSnapin Microsoft.SharePoint.PowerShell
}
#Get the Web
$web=Get-SPWeb "https://sharepoint.company.com"
#Get the List/Library
$list=$web.Lists.TryGetList("SalesList")
If($list) #Check If List exists!
{
#Check Folder Doesn't exists in the Library!
$folder = $list.ParentWeb.GetFolder($list.RootFolder.Url + "/" +"Sales List");
#sharepoint powershell check if folder exists
If($folder.Exists -eq $false)
{
#Create a Folder
$folder = $list.AddItem([string]::Empty, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "Sales Sub-Item")
$folder.Update();
}
#Create a Sub-Folder "APAC Sales Documents" inside "Sales Documents"
$Subfolder = $list.ParentWeb.GetFolder($folder.URL + "/" + "APAC Sales Documents");
#Check if sub-folder doesn't exist already
If ($Subfolder.Exists -eq $false)
{
#Create a Sub-Folder Inside "Sales Documents"
$Subfolder = $list.AddItem($folder.URL, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "APAC Sales Documents")
$Subfolder.Update();
}
}
How about ensuring a nested folder structure in SharePoint Library? E.g. Library/FolderA/FolderAA/FolderAAA
#Get the Web
$web=Get-SPWeb "https://sharepoint.company.com"
#Get the List/Library
$list=$web.Lists.TryGetList("Documents")
#Function to Ensure FolderPath
Function Ensure-FolderPath($FolderPath)
{
$SubFolders = $FolderPath -split "/"
$RootFolder = $SubFolders[0]
$SubfolderPath = $RootFolder
For($i =1; $i -le $SubFolders.count-1; $i++)
{
$SubfolderPath = $SubfolderPath+"/"+$SubFolders[$i]
$Folder = $Web.GetFolder($SubfolderPath)
#Create Folder if it doesn't exists
If($Folder.Exists -eq $false)
{
$TargetFolder = $Web.Folders.Add($SubfolderPath)
Write-host "Folder Created:"$SubfolderPath
}
}
}