0

I'm having a list of folder names which has lengthy names. Is it possible to change only the internal names of the folders inside SharePoint Document library which will reduce the length of the url?

VirK
  • 1

1 Answers1

0

We can add new column to store the old folder name, then using the code below to set change the folder name in document library.

string targetSiteURL = @"https://xx.sharepoint.com/sites/xx";

var login = "xx@xxx.onmicrosoft.com";
var password = "xxx";

var securePassword = new SecureString();

foreach (char c in password)
{
    securePassword.AppendChar(c);
}
SharePointOnlineCredentials onlineCredentials = new SharePointOnlineCredentials(login, securePassword);

ClientContext ctx = new ClientContext(targetSiteURL);
ctx.Credentials = onlineCredentials;

var list = ctx.Web.Lists.GetByTitle("Documents");

var folderItem = list.GetItemById(12);            
folderItem["FileLeafRef"] = "TestFolder";
folderItem.Update();
ctx.ExecuteQuery();
LZ_MSFT
  • 4,079
  • 1
  • 8
  • 9