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
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
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 *
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")
Apply a modern theme:
tb.Style("darkly")
๐งฎ 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)
We also track sync progress.
sync_running = False
auto_sync = False
total_files = 0
processed_files = 0
๐ 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()
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()
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}")
Or if they need updating.
if os.path.getmtime(src_file) > os.path.getmtime(dst_file):
preview_list.insert("end", f"UPDATE โ {file}")
This provides a safe preview before syncing.
๐ Step 8 โ The Sync Engine
This is the core of the application.
def sync_folders():
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))
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
If the file exists, compare hashes.
if calculate_hash(src_file) != calculate_hash(dst_file):
copy_required = True
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():
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)
This keeps folders perfectly synchronized.
โฑ Step 10 โ Automatic Sync
Auto sync runs the process every minute.
def auto_sync_loop():
Start continuous synchronization.
while auto_sync:
sync_folders()
Pause between cycles.
time.sleep(1)
This allows hands-free backup automation.
๐ Step 11 โ Folder Selection
Users must choose source and target folders.
def browse_source():
folder = filedialog.askdirectory()
Update the variable.
source_folder.set(folder)
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"
)
Then create the control buttons.
tb.Button(
frame_controls,
text="๐ Start Sync",
bootstyle="success",
command=lambda: threading.Thread(
target=sync_folders,
daemon=True
).start()
)
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)
Users can inspect changes before syncing.
๐ Step 14 โ Activity Log
We also create a log console.
log_text = tk.Text(log_frame, height=16)
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"
)
The sync engine updates it dynamically.
โถ๏ธ Step 16 โ Start the App
Run the Tkinter event loop.
app.mainloop()
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)