How to Batch Rename Thousands of PDF Files from Excel
Question details
The user needs to rename thousands of PDF files automatically using a list of current and desired file names stored in an Excel spreadsheet.

- Product
- Excel
- Device & OS
- Windows
- Scenario
- Managing a large number of PDF files that require systematic renaming based on spreadsheet data without doing it manually.
- Observed behavior
- Renaming thousands of files manually is too time-consuming, necessitating an automated script or batch process using Excel and the operating system.
Back up your original PDF files into a separate folder before attempting any bulk renaming, and test the batch process on a small sample of 5 to 10 files first to ensure the script works exactly as expected.
Use Excel Formulas and Windows Command Prompt
Generate a batch rename script using an Excel formula to combine your old and new file names, then execute it via the Windows Command Prompt (.bat file).
Batch renaming is natively handled by the Windows operating system rather than PDF readers. By using a spreadsheet to write the commands, you can instantly rename thousands of files.
Open your spreadsheet. In Column A, list the exact current file names (including the .pdf extension). In Column B, list the desired new file names (also including the .pdf extension).
In Column C (cell C2), enter the formula: ="REN "&CHAR(34)&A2&CHAR(34)&" "&CHAR(34)&B2&CHAR(34) . This creates a command that safely wraps your filenames in quotation marks to handle any spaces.
Select cell C2 and drag the fill handle down to apply this formula to all rows containing your file names.
Select all the generated text in Column C and copy it. Open the Windows Notepad application, paste the copied commands, and go to File > Save As.
Save the file as 'rename_files.bat' directly into the exact folder where your PDF files are located. Double-click this .bat file to execute the script and rename all PDFs instantly.

Use an Excel VBA Macro
Create a custom VBA macro in Excel to loop through your list and rename the files directly without needing the Command Prompt.
Batch Rename Files Using WPS Spreadsheet
You can easily generate bulk rename commands using WPS Spreadsheet. It offers full compatibility with Microsoft Excel formulas, allowing you to seamlessly create batch scripts for Windows file management.
- 1. Open your file list: Launch WPS Spreadsheet and organize your old file names in Column A and new file names in Column B.
- 2. Use the formula: In a blank column, enter the formula ="REN "&CHAR(34)&A2&CHAR(34)&" "&CHAR(34)&B2&CHAR(34) to create the DOS rename command.
- 3. Export to Notepad: Copy the output, paste it into Notepad, and save it as a .bat file inside your target PDF directory.
- 4. Execute the batch: Run the .bat file to instantly rename your PDFs directly from your Windows folder.

Frequently Asked Questions
Do I need to include the .pdf extension in my spreadsheet list?
Yes, both the current filename and the new filename must include the .pdf extension for the Windows Command Prompt to correctly identify and rename the files without losing their format.
What happens if a file name contains spaces?
To handle spaces in file names safely, your rename command must wrap the file names in double quotation marks. Using the formula with CHAR(34) ensures that spaces do not break the command sequence.
Can I use this method to rename files other than PDFs?
Absolutely. The 'REN' command in Windows works for any file type. Just ensure you use the corresponding correct file extension (like .docx, .jpg, or .xlsx) in your spreadsheet columns.
Why didn't my .bat file rename the PDFs?
This usually happens if the .bat file is not saved in the exact same folder as the PDFs, or if the current names in your Excel list do not perfectly match the actual file names on your computer.




