Reputation: 1
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?
Upvotes: 0
Views: 593
Reputation: 4228
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 = "[email protected]";
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();
Upvotes: 0