OneDrive File Issues

How to Rename Multiple OneDrive Files in Bulk Using PowerShell

Muhammad TalhaMuhammad Talha Oct 29, 2026 871 views

Question details

The user is looking for a way to automatically rename multiple files at once in OneDrive or SharePoint using PowerShell.

How to Rename Multiple OneDrive Files in Bulk 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.
Before you start

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.

Solution 1Recommended

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.

1
Install PnP PowerShell

Open your PowerShell console as an Administrator and run the command 'Install-Module PnP.PowerShell' to download the required cmdlets.

2
Connect to Your Environment

Run the command 'Connect-PnPOnline -Url "Your-Site-URL" -Interactive' to securely authenticate into your SharePoint site or OneDrive for Business account.

3
Fetch the Target Files

Use the 'Get-PnPListItem' cmdlet targeting your specific document library to retrieve the list of files you wish to rename.

4
Apply New Names

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.

Automate Bulk Renaming Using PnP PowerShell Scripts
Script Modification Help: If you need help customizing your PowerShell script, the Microsoft Q&A forum is an excellent resource. Use the 'OneDrive for IT professionals' or 'SharePoint development' tags when posting your query.
Free Microsoft Office alternative

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. 1. Download the Installer: Visit the official WPS Office website and click the download button for your operating system.
  2. 2. Install WPS Office: Run the downloaded setup file and follow the straightforward on-screen instructions.
  3. 3. Manage Files Intuitively: Open WPS Office and utilize its built-in file manager to seamlessly organize your local and cloud documents.
Fully compatible with Microsoft Office file formats (.docx, .xlsx, .pptx).Lightweight software that runs quickly and smoothly on all major operating systems.Built-in WPS Cloud storage makes organizing and syncing files across devices effortless.Completely free to download and use for your daily productivity needs.
microsoft office alternative - wps office

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.