So you have a bunch of files (read thousands) that you need to rename. If you deal with documents/records in the workplace and you don’t have access to fancy EDRMS, EDMS, then you most probably resort to physical files (Word, PDF, etc.) on shared drives and some in-house classification systems.
In a real case scenario (where I work as a contractor) the team was implementing a new document naming convention, meaning that we needed to rename all the existing documents. And I don’t take “manually” as an answer.
Solution:
Excel is the corporate user’s best friend and in this example we’ll be using it to solve our problem.
1) Similar to this screenshot, in a spreadsheet list the documents you need to rename.
Each row represents an existing document file. First column contains the current filename and the 2nd column is the new filename.
2) In the Macros window (in Excel) insert the following code:
3.1) Change the paths in lines 10 and 11 to match yours. You can use network addresses like"\\network\path\"
too.
3.2) Change the cell range in line 15. The code currently copies and renames 10 files.
3.3) Make sure the source and destination paths in lines 10 and 11 of the code exist. Create them if they don’t.
4) Run the macro. depending on the number of rows included in the range it make take a few minutes for the macro to finish. You may want to remove/move the original files now.
Note: If Excel crashed or stayed unresponsive for a long time, try smaller ranges.
Genesis
Would you have a sample spreadsheet for this macro?
Audra
This is a really good code, however, the screenshot is misleading, as column A should be a new title while column B should be the existing title, at least the way the code is written.
Thank you for sharing this,
Audra
Sandeep
Above Code didn’t work’s for Me.
Please suggest user type not define exception is throwing.
RandyL
Sandeep – follow directions in this link https://stackoverflow.com/questions/3233203/how-do-i-use-filesystemobject-in-vba
Hemin Sultan
Also, you can try this one, a combination of DOS and excel. https://benholland.me/tutorials/2011/11/11/rename-multiple-files-using-excel-in-windows.html