A package to track file changes in a directory
Project description
trackdir
trackdir is a Python package designed to monitor and track changes in a specified directory. It detects file creations, deletions, and modifications, providing real-time feedback either as a command-line tool or as a Python module in your scripts.
Features
- Real-Time Monitoring: Instantly detects file creations, deletions, and modifications.
- Flexible Usage: Can be used both as a command-line tool and a Python module.
- Detailed Change Information: Returns detailed information about the type of change and the affected file.
Installation
You can install the trackdir
package using pip
:
pip install trackdir
Usage
Command-Line Tool
To monitor a directory from the command line:
trackdir C:/telegram
This command will print details of any file changes (creation, deletion, modification) detected in the specified directory.
Python Module
You can also use trackdir
within your Python scripts:
from trackdir import track_changes
# Track changes in the specified directory
change = track_changes("C:/telegram")
if change:
event_type = change["type"]
event_path = change["path"]
if event_type == 'modified':
print(f"File modified: {event_path}")
elif event_type == 'created':
print(f"File created: {event_path}")
elif event_type == 'deleted':
print(f"File deleted: {event_path}")
Example
Here’s an example of using trackdir
in a Python script:
from trackdir import track_changes
directory_to_monitor = "C:/telegram"
# Continuously monitor the directory
while True:
change = track_changes(directory_to_monitor)
if change:
event_type = change["type"]
event_path = change["path"]
print(f"Detected {event_type} at {event_path}")
Contributions
Contributions are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Special thanks to the watchdog library, which powers the file system monitoring capabilities of this package.
Thank You
A heartfelt thank you to everyone who has supported and contributed to this project. Your encouragement and feedback are deeply appreciated and motivate me to continue improving and innovating.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file trackdir-1.0.0.tar.gz
.
File metadata
- Download URL: trackdir-1.0.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5bd7a458cae4aafd6908da638087999b4d6e38dc63ab0c8d44922d85122ed1f |
|
MD5 | 5f9133c2d7885538ef75bdafdfe2dfe6 |
|
BLAKE2b-256 | c4fa1875f25352b1d4ff6da071fbf85567a33946c43612f6e3d57b4e31d459dd |