DEV Community

Mate Technologies
Mate Technologies

Posted on

Real-Time File Synchronization with FileSync PRO v3.0.0

FileSync PRO is a professional desktop tool for real-time folder synchronization, backup automation, and advanced file management. This guide walks you through its setup, usage, and key code features.

Download FileSync PRO v3.0.0

🏗 Architecture Diagram
+----------------+ +----------------+ +----------------+
| Source Folder | --> | FileSync PRO | --> | Target Folder |
| (Watched) | | (Sync Engine) | | (Mirrored) |
+----------------+ +----------------+ +----------------+
^ |
| |
| v
Filters Activity Log
(File types, hash) Progress Bar

Explanation:

Source Folder: Where your files live.

FileSync PRO: Monitors, compares, and copies files.

Target Folder: Destination folder. Supports mirror mode.

Filters & Hash Verification: Optional, ensures integrity.

Activity Log & Progress Bar: Visual feedback for sync operations.

1️⃣ Setup Your Python Environment

FileSync PRO relies on:

Python 3.x

tkinter (GUI)

ttkbootstrap (modern styling)

watchdog (real-time folder monitoring)

Install dependencies:

pip install ttkbootstrap watchdog
Enter fullscreen mode Exit fullscreen mode

tkinter comes built-in with most Python installations.

2️⃣ App Configuration

APP_NAME = "FileSync PRO"
APP_VERSION = "3.0.0"

source_folder = tb.StringVar()
target_folder = tb.StringVar()
filter_ext = tb.StringVar(value="")
mirror_mode = tb.BooleanVar(value=False)
verify_hash = tb.BooleanVar(value=True)
Enter fullscreen mode Exit fullscreen mode

Explanation:

source_folder and target_folder store folder paths.

filter_ext lets you sync only specific file types (.txt, .pdf, etc.).

mirror_mode deletes target files not present in the source.

verify_hash ensures file integrity by comparing MD5 hashes.

3️⃣ Logging & Utility Functions

def log(msg):
    ui_queue.put(("log", msg))

def hash_file(path):
    md5 = hashlib.md5()
    with open(path,"rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            md5.update(chunk)
    return md5.hexdigest()
Enter fullscreen mode Exit fullscreen mode

Explanation:

log(msg) pushes messages to the activity log.

hash_file(path) calculates a file’s MD5 hash for verification.

4️⃣ File Synchronization

def sync_file(src_file, dst_file):
    os.makedirs(os.path.dirname(dst_file), exist_ok=True)
    copy_required = not os.path.exists(dst_file) or \
                    os.path.getmtime(src_file) > os.path.getmtime(dst_file)
    if copy_required:
        shutil.copy2(src_file, dst_file)
        log(f"✔ Synced: {os.path.basename(src_file)}")
Enter fullscreen mode Exit fullscreen mode

Explanation:

Checks if the file exists in the target folder.

Copies only if new or modified.

Logs each synced file for user visibility.

5️⃣ Full Folder Sync

def full_sync():
    if not source_folder.get() or not target_folder.get():
        messagebox.showerror("Error","Select folders first")
        return
    for root, dirs, files in os.walk(source_folder.get()):
        for f in files:
            if allowed_file(f):
                src_file = os.path.join(root, f)
                dst_file = os.path.join(target_folder.get(), os.path.relpath(src_file, source_folder.get()))
                sync_file(src_file, dst_file)
Enter fullscreen mode Exit fullscreen mode

Explanation:

Recursively traverses the source folder.

Syncs only allowed files.

Optionally mirrors deletions when mirror_mode is enabled.

6️⃣ Real-Time Folder Monitoring

class SyncHandler(FileSystemEventHandler):
    def on_modified(self, event):
        if event.is_directory: return
        src = event.src_path
        if allowed_file(src):
            dst = os.path.join(target_folder.get(), os.path.relpath(src, source_folder.get()))
            sync_file(src, dst)
Enter fullscreen mode Exit fullscreen mode

Explanation:

Uses watchdog to detect changes.

Syncs files immediately when modified, created, or deleted.

7️⃣ Starting & Stopping Real-Time Sync

def start_realtime_sync():
    handler = SyncHandler()
    global observer
    observer = Observer()
    observer.schedule(handler, source_folder.get(), recursive=True)
    observer.start()
    log("⚡ Real-time sync started")

def stop_realtime_sync():
    global observer
    if observer:
        observer.stop()
        observer.join()
        log("🛑 Real-time sync stopped")
Enter fullscreen mode Exit fullscreen mode

Explanation:

Start the observer to monitor changes continuously.

Stop the observer safely when done.

8️⃣ GUI Controls

tb.Button(frame_controls, text="🔄 Full Sync", bootstyle="success",
          command=lambda: threading.Thread(target=full_sync, daemon=True).start()).pack(side="left")

tb.Button(frame_controls, text="⚡ Start Real-Time Sync", bootstyle="warning",
          command=start_realtime_sync).pack(side="left")
Enter fullscreen mode Exit fullscreen mode

Explanation:

Buttons trigger full sync or start real-time monitoring.

Threads prevent UI freezing during sync operations.

9️⃣ Activity Log & Progress Bar

log_text = tk.Text(log_frame, height=14)
progress = tb.Progressbar(app, bootstyle="success-striped")
Enter fullscreen mode Exit fullscreen mode

Explanation:

log_text displays synced files and errors.

progress shows the current sync progress.

1️⃣0️⃣ About FileSync PRO

def show_about():
    messagebox.showinfo(f"About {APP_NAME}",
                        f"{APP_NAME} v{APP_VERSION}\n"
                        "Real-time sync, backup automation, file mirroring.\n\n"
                        "Built with Python, Tkinter, ttkbootstrap, watchdog.")
Enter fullscreen mode Exit fullscreen mode

Explanation:

Provides users information about the tool and core features.

Highlights technologies used.

🚀 Conclusion

FileSync PRO v3.0.0 offers:

Real-time folder monitoring

Full sync and mirror mode

File extension filtering

Hash verification for file integrity

Activity logs and progress indicators

For the latest version and binaries: Download FileSync PRO v3.0.0

Top comments (0)