DEV Community

Mate Technologies
Mate Technologies

Posted on

๐Ÿš€ Build a Professional File Synchronization Tool in Python (Tkinter + ttkbootstrap)

Build a modern desktop file synchronization tool with Python โ€” complete with preview mode, hash verification, auto sync, and a beautiful UI.

In this tutorial you'll learn how to build FileSync PRO, a powerful desktop tool for:

โœ” Folder backup
โœ” Directory mirroring
โœ” Incremental file synchronization
โœ” File integrity verification
โœ” Automated background syncing

This project is perfect for:

Python developers

DevOps engineers

Researchers managing large datasets

Anyone needing reliable local backups

๐Ÿ“ฆ Project Download

You can download the full release here:

๐Ÿ‘‰ https://github.com/rogers-cyber/FileSyncPRO/releases/tag/v2.0.0

๐Ÿง  What We'll Build

A professional desktop app that can:

Feature Description
Preview Changes See what files will change before syncing
Smart Sync Only copy modified files
Mirror Mode Remove outdated files
Auto Sync Run synchronization automatically
Hash Verification Ensure files are identical
Progress Tracking Visual sync progress
Activity Logs Monitor operations
๐Ÿ— Application Architecture
+-------------------------+
| UI Layer |
| Tkinter + ttkbootstrap |
+-----------+-------------+
|
v
+-------------------------+
| Control Layer |
| Preview / Sync / Log |
+-----------+-------------+
|
v
+-------------------------+
| Sync Engine |
| File Scan + Hash Check |
+-----------+-------------+
|
v
+-------------------------+
| File System |
| Source โ†” Target folders |
+-------------------------+

The application has three main components:

1๏ธโƒฃ User Interface
2๏ธโƒฃ Sync Engine
3๏ธโƒฃ Filesystem Operations

โš™๏ธ Step 1 โ€” Install Dependencies

We only need one extra UI library.

pip install ttkbootstrap

Why ttkbootstrap?

Because it gives modern dark UI themes for Tkinter.

๐Ÿงฉ Step 2 โ€” Import Required Libraries

Start by importing the modules we need.

import os
import sys
import shutil
import threading
import time
import traceback
import hashlib
Enter fullscreen mode Exit fullscreen mode

These handle:

file management

background threads

error handling

hashing

Next we import datetime and queue utilities.

from datetime import datetime
from queue import Queue, Empty
Enter fullscreen mode Exit fullscreen mode

These are used for progress updates and UI messaging.

๐Ÿ–ฅ Step 3 โ€” Import the GUI Framework

Now we import Tkinter and ttkbootstrap.

import tkinter as tk
from tkinter import filedialog, messagebox

import ttkbootstrap as tb
from ttkbootstrap.constants import *
Enter fullscreen mode Exit fullscreen mode

This gives us:

modern UI styling

better buttons

dark themes

๐Ÿงพ Step 4 โ€” App Configuration

Let's define our app metadata.

APP_NAME = "FileSync PRO"
APP_VERSION = "2.0.0"

Now create the application window.

app = tk.Tk()
app.title(f"{APP_NAME} {APP_VERSION}")
app.geometry("1200x650")

Enter fullscreen mode Exit fullscreen mode

Apply a modern theme:

tb.Style("darkly")
Enter fullscreen mode Exit fullscreen mode

๐Ÿงฎ Step 5 โ€” Global Variables

These variables track app state.

ui_queue = Queue()

source_folder = tb.StringVar()
target_folder = tb.StringVar()

mirror_mode = tb.BooleanVar(value=False)
Enter fullscreen mode Exit fullscreen mode

We also track sync progress.

sync_running = False
auto_sync = False

total_files = 0
processed_files = 0
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” Step 6 โ€” File Integrity with Hashing

We use MD5 hashing to ensure files are identical.

def calculate_hash(file_path):

    md5 = hashlib.md5()

    with open(file_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

Why hashing?

Because timestamps alone are not always reliable.

Hashing guarantees file integrity.

๐Ÿ”Ž Step 7 โ€” Preview Changes Before Sync

Before copying files, it's useful to preview the changes.

def preview_changes():

    src = source_folder.get()
    dst = target_folder.get()

Enter fullscreen mode Exit fullscreen mode

We scan the source directory.

for root, dirs, files in os.walk(src):

Then check if files exist in the target folder.

if not os.path.exists(dst_file):
    preview_list.insert("end", f"NEW โ†’ {file}")
Enter fullscreen mode Exit fullscreen mode

Or if they need updating.

if os.path.getmtime(src_file) > os.path.getmtime(dst_file):
    preview_list.insert("end", f"UPDATE โ†’ {file}")
Enter fullscreen mode Exit fullscreen mode

This provides a safe preview before syncing.

๐Ÿ”„ Step 8 โ€” The Sync Engine

This is the core of the application.

def sync_folders():
Enter fullscreen mode Exit fullscreen mode

First we scan all files.

for root, dirs, files in os.walk(src):
    for f in files:
        file_list.append(os.path.join(root, f))
Enter fullscreen mode Exit fullscreen mode

Then process them one by one.

for src_file in file_list:

Check if copying is needed.

if not os.path.exists(dst_file):
    copy_required = True
Enter fullscreen mode Exit fullscreen mode

If the file exists, compare hashes.

if calculate_hash(src_file) != calculate_hash(dst_file):
    copy_required = True
Enter fullscreen mode Exit fullscreen mode

Then copy the file.

shutil.copy2(src_file, dst_file)
๐Ÿงน Step 9 โ€” Mirror Mode

Mirror mode removes files that no longer exist in the source.

if mirror_mode.get():
Enter fullscreen mode Exit fullscreen mode

Scan the destination folder.

for root, dirs, files in os.walk(dst):

Delete extra files.

if not os.path.exists(src_file):
    os.remove(dst_file)
Enter fullscreen mode Exit fullscreen mode

This keeps folders perfectly synchronized.

โฑ Step 10 โ€” Automatic Sync

Auto sync runs the process every minute.

def auto_sync_loop():
Enter fullscreen mode Exit fullscreen mode

Start continuous synchronization.

while auto_sync:
    sync_folders()
Enter fullscreen mode Exit fullscreen mode

Pause between cycles.

time.sleep(1)
Enter fullscreen mode Exit fullscreen mode

This allows hands-free backup automation.

๐Ÿ“ Step 11 โ€” Folder Selection

Users must choose source and target folders.

def browse_source():
    folder = filedialog.askdirectory()
Enter fullscreen mode Exit fullscreen mode

Update the variable.

source_folder.set(folder)
Enter fullscreen mode Exit fullscreen mode

Same for the target folder.

๐Ÿ–ฅ Step 12 โ€” Build the UI Layout

Create the title header.

tb.Label(
    title_frame,
    text=APP_NAME,
    font=("Segoe UI", 26, "bold"),
    bootstyle="primary"
)
Enter fullscreen mode Exit fullscreen mode

Then create the control buttons.

tb.Button(
    frame_controls,
    text="๐Ÿ”„ Start Sync",
    bootstyle="success",
    command=lambda: threading.Thread(
        target=sync_folders,
        daemon=True
    ).start()
)
Enter fullscreen mode Exit fullscreen mode

We run syncing in threads to keep the UI responsive.

๐Ÿ“Š Step 13 โ€” Preview Panel

The preview panel shows pending changes.

preview_list = tk.Listbox(preview_frame, height=16)
Enter fullscreen mode Exit fullscreen mode

Users can inspect changes before syncing.

๐Ÿ“œ Step 14 โ€” Activity Log

We also create a log console.

log_text = tk.Text(log_frame, height=16)
Enter fullscreen mode Exit fullscreen mode

Every action appears in the log:

โœ” Synced: report.csv
๐Ÿ—‘ Deleted: old_data.json
๐Ÿ“ˆ Step 15 โ€” Progress Tracking

Finally we add a progress bar.

progress = tb.Progressbar(
    app,
    bootstyle="success-striped"
)

Enter fullscreen mode Exit fullscreen mode

The sync engine updates it dynamically.

โ–ถ๏ธ Step 16 โ€” Start the App

Run the Tkinter event loop.

app.mainloop()
Enter fullscreen mode Exit fullscreen mode

And your professional desktop sync tool is ready.

๐ŸŽฏ Real-World Use Cases

This tool can be used for:

Local backups

Dataset replication

Dev project mirroring

NAS synchronization

Automated research backups

๐Ÿš€ Possible Improvements

You could extend the tool with:

Cloud backup support

file version history

real-time filesystem monitoring

multi-threaded copying

encryption

โญ Final Thoughts

In this tutorial you built a complete desktop backup and synchronization system using:

Python

Tkinter

ttkbootstrap

This is the kind of project that demonstrates real engineering skills.

It combines:

UI development

filesystem automation

hashing

multithreading

๐Ÿ“š Project Release

Download the full release here:

๐Ÿ‘‰ https://github.com/rogers-cyber/FileSyncPRO/releases/tag/v2.0.0

Top comments (0)