Tuesday, April 16, 2013

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 "http://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
              #Replace "Crescent" with "Crescent Inc."
              $ListItem["Name"] = $ListItem["Name"].replace("Crescent","Crescent Inc.")
              #Update the changes
              #$ListItem.File.CheckIn("Updated the File Name")

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. splistitem doesn't have a "replace" method. The above will never work.


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...