Rename Files / Find and Replace File Names in SharePoint Document Library with PowerShell

Here is the PowerShell script to rename all files in bulk in SharePoint library:

#Get the Web  
$Web = Get-SPWeb "https://sharepoint.crescent.com"

#Get the List
$List = $Web.Lists["Design Documents"]

#Iterate Through All List Items
foreach($ListItem in $List.Items)
{
	if($null -ne $ListItem.File) #Exclude Document Sets
	{
		Write-Host "Checking $($ListItem.Name)..."
		#Check out, if Require checkout is enabled
		#$ListItem.File.CheckOut()
		#Replace "Crescent" with "Crescent Inc."
		$ListItem["Name"] = $ListItem["Name"].replace("Crescent","Crescent Inc.")
		#Update the changes
		$ListItem.Update()
		#$ListItem.File.CheckIn("Updated the File Name")
	}
}

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “Rename Files / Find and Replace File Names in SharePoint Document Library with PowerShell

  • How can we do this Bulk if we have about 200 documents with similar names?

    Please advise?

    Reply
  • disregard my comment…

    Reply
  • splistitem doesn’t have a “replace” method. The above will never work.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *