I am wanting to rename a file name in a document library called "RenameAFile". Currently have the following file called "UD-PD-Documentattion.xlsx"

and I want add "DN" before the file name "UD-PD-Documentattion.xlsx".



Is this possible? Would anyone able to help?


  • when you want to change the file, once it uploaded or during the upload process or what? – Waqas Sarwar MVP Dec 6 '18 at 22:52

I manage to figure it out.

$Web = Get-SPWeb "http://yoursite.com/documentlib"
$DocLib = $Web.Lists["RenameAFile"]          
foreach($ListItem in $DocLib.Items)
             $ListItem["Name"] = "DN-"+$ListItem["Name"]
             $ListItem["Title"] = "Add DN"
         $ListItem.File.CheckIn("File Name Updated")     
| improve this answer | |

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.