Construction and engineering firms deal with mountains of documents daily. Keeping track of the latest revisions, ensuring everyone’s working from the correct version, and archiving old files can be a real headache. I recently helped Reci, an engineering firm, tackle this challenge by automating their file management process using Python.
The Problem: Manual File Sorting is Time-Consuming and Prone to Errors
Reci’s technicians create new files and place them in a designated “For Posting” folder. The administrator then has to manually sort through this folder, moving documents and drawings to the “Active” (current files) and “Archive” (old versions) directories. This process was time-consuming and, like any manual task, prone to errors. Imagine accidentally moving the wrong version of a critical drawing! The goal was simple: automate this process to save time and reduce the risk of mistakes.
My Approach: Python to the Rescue (and Ditching Power Automate)
My first step, as always, was to map out the existing process flow. I needed to understand exactly how files were currently managed and identify any potential bottlenecks or points of failure. While waiting for Reci to confirm my assumptions, I began exploring potential solutions.
Initially, I considered using Power Automate. However, I quickly realized it wasn’t the ideal tool for the job. The workflow was becoming unnecessarily complex, and many of the required actions were premium features, limiting the number of times the workflow could run. Plus, I knew this was just the first step. We eventually planned to integrate drawing block checking and PDF signatures into the workflow, and Power Automate would become even more cumbersome. That’s where Python came in.
Python offered the flexibility and power I needed. It’s a versatile language capable of handling complex file management tasks, and it integrates well with other tools we might need down the line. The biggest hurdle was ensuring Python code could be executed within Reci’s existing infrastructure, namely on the server computer where all shared files are hosted.
The Solution: A Python Script for Automated File Management
The core of the solution is a Python script that runs automatically on a scheduled basis. Here’s how it works:
- Scheduled Execution: The script is set to run every four hours using a cron job.
- Directory Monitoring: The script checks each project folder for new files in the “For Posting” folder.
- File Processing: If a new file is found, the script moves it to both the “Active” and “Archive” directories.
Important Consideration: This initial version assumes that any new file in the “For Posting” directory is the latest revision and should replace any existing file in the “Active” directory. This highlights the crucial role of consistent file naming conventions, something we may need to address in future iterations.
The Code (Simplified):
While I can’t share the exact code, here’s a simplified example to illustrate the core logic:
import os
import shutil
def process_files(project_folder):
for filename in os.listdir(os.path.join(project_folder, "For Posting")):
source_path = os.path.join(project_folder, "For Posting", filename)
active_path = os.path.join(project_folder, "Active", filename)
archive_path = os.path.join(project_folder, "Archive", filename)
# Move existing file to archive (if it exists)
if os.path.exists(active_path):
shutil.move(active_path, archive_path)
# Move new file to active
shutil.move(source_path, active_path)
Lessons Learned and Next Steps:
This project demonstrates the power of Python for automating even seemingly simple tasks. It also highlights the importance of understanding existing infrastructure and choosing the right tool for the job. While Power Automate is great for some workflows, Python offered the flexibility and scalability Reci needed.
Future improvements could include:
- Revision Control: Implementing a more robust revision control system to ensure the correct versions are always used.
- Drawing Block Checking: Integrating drawing block checking to automatically verify key information on drawings.
- PDF Signature Integration: Automating the process of adding digital signatures to PDFs.
Could Your Firm Benefit from Automation?
At Construct Digitally, I help engineering, architectural, and construction firms like Reci streamline their workflows and digitize manual processes. Whether it’s file management, document workflows, or QA processes, I can design custom solutions tailored to your specific needs.
If you’re tired of spending countless hours on repetitive tasks, let’s talk. Visit Construct Digitally to learn more about my services, including script development & automation, workflow design & implementation, and CDE integration & optimization. Let’s explore how we can make your firm more efficient and productive. You can also learn more about similar projects by subscribing to my newsletter!
Leave a Reply