3

I want to change the file names and switch columns in SharePoint. (Name to Title, Code to Name).

There are about 1,000 files in the library.

How I can rename multiple files faster than by managing the list items using Quick Edit?

  • If you want to work with a list quickly in SharePoint, step one is definitely "don't use Quick Edit". – TylerH Mar 10 at 15:14
6

One way to do this is by creating a PowerShell script, the PnP PowerShell Library is a popular choice to manage SharePoint (both on premise and online).

Example follows to mass update a list. Note that the Name columns internal name is FileLeafRef.

Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/sitename  -Credentials (Get-Credential)
$listitems = Get-PnPListItem -List "Your list name"

foreach ($item in $listitems) {
  Write-Output "Processing item $($item.ID)"
  $item["Title"] = $item["FileLeafRef"]
  $item["FileLeafRef"] = $item["Code"]
  $item.Update() 
  ## use $item.SystemUpdate() to preserve modified information
}
Invoke-PnPQuery
Disconnect-PnPOnline
| improve this answer | |
2

Rune's script is great. One thing to add is that you it may be better to use

Connect-PnPOnline -Url https://domain.sharepoint.com/sites/sitename -Credentials (Get-Credential)

There are chances user is using another account to login the machine. It may cause some trouble if end user have no idea about PowerShell.

You will need to have SharePoint Online Management Shell to run scripts.

Another out of the box option is to use a Power Automate flow. A sample flow like below will create a new file with new name and then update the properties according to your requirements. It is not a perfect solution as it runs much slower than PowerShell, and Power Automate does not allow us to change file names; we have to create new ones and delete the old ones. And as the code column often does not include the extension, you may need to do other work to have the correct extension.

I only provide this as an option if you really do not want to use a PowerShell Script.

enter image description here

| improve this answer | |
  • Great suggestion on the credentials. I always use managed credentials myself, so I leave it blank in examples :-) I will update my answer! – Rune Sperre Mar 10 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.