Author: PythonHubStudio / Oleksandr Tukas
Language: Python 3.11+
License: MIT
DirTracker — This tool creates a "snapshot" of a directory (its full tree structure). It detects any file changes since the last check, including:
- 🟢 files that were added;
- 🔴 files that were removed;
- 🟡 files whose contents have changed, even by one byte.
For each directory you monitor, a snapshot file (.snapshot.pkl) is created in the directory itself.
With full absolute paths (if os.walk() was run from an absolute path):
[+] New file: /home/user/course/app.py
[-] Removed file: /home/user/Documents/passport.pdf
[~] Changed file: /home/user/Documents/contacts.xlsx
Or with relative paths (if os.walk() was run from "."):
[+] New file: ./course/app.py
[-] Removed file: ./Documents/passport.pdf
[~] Changed file: ./Documents/contacts.xlsx
💡 If redirect stdout, ANSI colors will be off.
python dtr.py [-h] [path]Arguments:
path— the path to the directory you want to monitor, if not passed it uses CWD-h— see help
Examples:
python dtr.py
python dtr.py /home/user/DocumentsOn Windows, ANSI colors are supported automatically (without using colorama).
Используется как образовательный пример в моем курсе: Used as an educational example in my course: 👉 Python Full Course on Udemy
DirTracker/
├── dtr.py # Entry point (CLI)
├── core/
│ ├── dirtracker.py
│ ├── ansi/
│ │ ├── fix.py # Enables ANSI colors on Windows
│ │ └── colorize.py # Cross-platform color formatting
│ └── settings/
│ ├── conf_reader.py # Read the config file
│ └── excludes_reader.py # Read the excludes names.
└── settings/
├── config.conf
├── excludes_dirs.conf
└── excludes_files.conf
- Detects added, removed, and changed files
- Stores snapshot in
.snapshot.pkl - Automatically disables colors for redirected output
- Works cross-platform (Linux, macOS, Windows)
- Simple CLI interface using
argparse
This project is distributed under the MIT License. See the LICENSE file for details.