Engineering projects generate thousands of files: drawings, calculations, reports, correspondence, submittals, and shop drawings. Every company has a naming convention — project number, discipline code, document type, revision number — but manually renaming files to match is tedious and error-prone. When a project has 500 drawings that arrived from a subconsultant with their naming convention, someone has to rename every single file. That someone should be a script, not a person.
Support three common renaming operations:
This is the most critical feature. Display the current filename alongside the proposed new filename in a two-column table. Let the user review every change before committing. Highlight any conflicts — two files that would end up with the same name, or names that exceed the Windows path length limit. Never rename without preview. One wrong pattern applied to 500 files creates a mess that takes longer to fix than the original manual renaming.
Save a rename log — a JSON file mapping new names back to original names. If something goes wrong, the undo function reads the log and reverses every rename operation. Store the log in the same directory as the renamed files, timestamped, so multiple rename operations each have their own recovery point.
Use a folder selection dialog to choose the target directory. Add filter options for file types (PDF only, Excel only, all files). Display the file list in a scrollable table with checkboxes so users can exclude specific files from the operation. Place the pattern input and rename button prominently above the preview table.
# Python: batch rename engineering documents
import os
import re
def batch_rename(folder, pattern, replacement):
# pattern uses regex; replacement can include \1, \2 groups
renamed = 0
for name in sorted(os.listdir(folder)):
new_name = re.sub(pattern, replacement, name)
if new_name != name:
src = os.path.join(folder, name)
dst = os.path.join(folder, new_name)
os.rename(src, dst)
print(f'{name} -> {new_name}')
renamed += 1
print(f'Renamed {renamed} files.')
# Example: add project prefix and fix numbering
# "DWG-001.pdf" -> "PRJ-2024-DWG-001.pdf"
batch_rename(
'C:/Projects/Drawings',
r'^(DWG-\d+)',
'PRJ-2024-\\1'
)
RHCES tools and training programs help engineers automate repetitive tasks. Explore our digital solutions catalog.
Explore RHCES Store →