How to Rename Multiple OneDrive Files in Bulk Using PowerShell
Question details
The user is looking for a way to automatically rename multiple files at once in OneDrive or SharePoint using PowerShell.

- Product
- Microsoft OneDrive for Business / SharePoint
- Device & OS
- not provided
- Scenario
- Organizing and standardizing file names across a large document library without manually renaming each file individually.
- Observed behavior
- OneDrive and SharePoint web interfaces lack a built-in bulk renaming tool, forcing users to rename items one by one unless they deploy an automated script or third-party tool.
Ensure you have the necessary administrative permissions to run PowerShell scripts in your Microsoft 365 environment, and always test your script on a small, isolated test folder before applying changes to your main library.
Automate Bulk Renaming Using PnP PowerShell Scripts
Utilizing a PnP PowerShell script allows you to connect directly to your SharePoint or OneDrive library and apply logic to rename multiple files efficiently.
PowerShell provides a robust way to interact with Microsoft 365 environments. By utilizing the SharePoint Patterns and Practices (PnP) PowerShell module, administrators can automate repetitive tasks like renaming bulk files.
If you are not comfortable writing the script from scratch, many community templates are available online. Minor modifications may be required depending on your specific naming convention.
Open your PowerShell console as an Administrator and run the command 'Install-Module PnP.PowerShell' to download the required cmdlets.
Run the command 'Connect-PnPOnline -Url "Your-Site-URL" -Interactive' to securely authenticate into your SharePoint site or OneDrive for Business account.
Use the 'Get-PnPListItem' cmdlet targeting your specific document library to retrieve the list of files you wish to rename.
Create a 'foreach' loop in your script that generates the new file name, then use 'Set-PnPListItem' to update the item's title and file name properties.

Sync to Local PC and Use Windows File Explorer
If scripting is too complex, you can sync your OneDrive files locally and use Windows' native batch renaming functionality.
Looking for a Lighter, Free Alternative to Microsoft Office?
If navigating complex admin tasks and PowerShell scripts in Microsoft 365 feels overwhelming, consider switching to a more intuitive suite for your everyday tasks. WPS Office provides an incredibly user-friendly experience for managing documents, spreadsheets, and presentations with built-in cloud storage integration.
- 1. Download the Installer: Visit the official WPS Office website and click the download button for your operating system.
- 2. Install WPS Office: Run the downloaded setup file and follow the straightforward on-screen instructions.
- 3. Manage Files Intuitively: Open WPS Office and utilize its built-in file manager to seamlessly organize your local and cloud documents.

Frequently Asked Questions
Can I bulk rename files directly in the OneDrive web interface?
No, the standard web interfaces for OneDrive and SharePoint currently only support renaming files one at a time. To bulk rename, you must utilize a PowerShell script, use Power Automate, or sync the files to your local computer.
Do I need special permissions to run PowerShell scripts against OneDrive for Business?
Yes, you typically need SharePoint Administrator rights or Site Owner permissions for the specific site or library to execute PowerShell cmdlets that modify multiple files.
Is it safe to use third-party tools to rename synced OneDrive files?
While third-party renaming utilities can be effective on locally synced files, they should be evaluated carefully. Always ensure the tool comes from a reputable source, and test it on a backup folder first, as bulk changes will immediately sync to the cloud and overwrite existing names.
What happens to the file version history when I rename a file via PowerShell?
Renaming a file generally preserves its version history in SharePoint and OneDrive. However, if your script physically moves the file or recreates it rather than using a proper update/rename cmdlet, the version history may be lost.




