简体中文版本在后面
A lightweight Python tool to automatically organize your Downloads folder using configurable rules (YAML).
Supports one-shot organizing and a watch mode that runs in the background and avoids moving files that are still downloading.
- Rule-based organization via YAML config
- Watch mode (
--watch) to organize automatically when files change - Avoids moving unfinished downloads:
- Ignores common temporary extensions (e.g.
.crdownload,.part,.tmp,.aria2) - Optional file stability check (size + mtime unchanged for N seconds)
- Ignores common temporary extensions (e.g.
- Dry run (
--dry-run) to preview actions without moving files - Automatic handling of name conflicts (adds
(1),(2)... suffix) - Optional logging to file (
--log-file) — recommended when running withpythonw.exe/ background
- Python 3.10+ (recommended)
- Windows/macOS/Linux
- Dependencies:
PyYAMLwatchdog(only required for--watchmode)
git clone https://github.com/<your-username>/Download_Organizer.git
cd Download_OrganizerWindows (PowerShell):
py -m venv .venv
.venv\Scripts\Activate.ps1macOS/Linux:
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtIf you don't have a requirements.txt yet, install manually:
pip install pyyaml watchdogCreate a config file, for example: configs/rules.yaml
Example:
download_dir: "your_path/Downloads"
destination_root: "your_path/Downloads/Sorted"
ignore_extensions:
- ".crdownload"
- ".part"
- ".tmp"
- ".download"
- ".opdownload"
- ".!qB"
- ".aria2"
rules:
- name: "Images"
extensions: [".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp"]
target: "Images"
- name: "Videos"
extensions: [".mp4", ".mkv", ".mov", ".avi", ".webm"]
target: "Videos"
- name: "Documents"
extensions: [".pdf", ".docx", ".doc", ".pptx", ".xlsx", ".md", ".txt"]
target: "Documents"
- name: "Archives"
extensions: [".zip", ".rar", ".7z", ".tar", ".gz"]
target: "Archives"
- name: "Installers"
extensions: [".exe", ".msi"]
target: "Installers"
- name: "CatchAll"
extensions: ["*"]
target: "Others"- Rules are matched top-to-bottom; the first match wins
extensions: ["*"]is a catch-all fallback- Prefer forward slashes (
C:/...) on Windows to avoid escaping issues
Preview actions:
python -m organizer.cli --config configs/rules.yaml --dry-run --verboseApply changes:
python -m organizer.cli --config configs/rules.yaml --verboseDry run watch:
python -m organizer.cli --config configs/rules.yaml --watch --dry-run --verboseActual watch:
python -m organizer.cli --config configs/rules.yaml --watch --verbose--stable-seconds: how long the file must remain unchanged before moving--debounce-seconds: reduce repeated triggers during heavy download activity
Example:
python -m organizer.cli --config configs/rules.yaml --watch --stable-seconds 4 --debounce-seconds 2 --verbosepython -m organizer.cli --config configs/rules.yaml --watch --log-file logs/watcher.log --verboseIf you want the organizer to run in the background without a console window:
- Open Task Scheduler → Create Task...
- General:
- Select Run only when user is logged on
- (Optional) check Run with highest privileges
- Triggers:
- At log on (optionally delay 30 seconds)
- Actions → Start a program:
- Program/script:
your_path\Download_Organizer\.venv\Scripts\pythonw.exe
- Add arguments:
-m organizer.cli --config "your_path\1AMainProjects\Download_Organizer\configs\rules.yaml" --watch --log-file "your_path\Download_Organizer\logs\watcher.log" --verbose
- Start in:
your_path\Download_Organizer
- Program/script:
Check logs at:
logs/watcher.log
Download_Organizer/
organizer/
cli.py
config.py
organizer.py
rules.py
utils.py
watch.py
configs/
rules.example.yaml
- More match types (regex filename, min/max size, date ranges)
- "Move only when download finished" integration for specific browsers/download managers
- Packaging as a standalone executable (PyInstaller)
- GUI configuration editor
PRs and issues are welcome!
If you report a bug, please include:
- your OS + Python version
- your config file (remove sensitive paths if needed)
- relevant log output (
--log-file)
一个轻量的 Python 工具,用可配置规则(YAML)自动整理 Downloads/下载 文件夹。
支持单次整理与监听模式(watch),并尽量避免移动“仍在下载/写入中”的文件。
- 使用 YAML 配置自定义整理规则
- 监听模式(
--watch):文件夹有变化就自动整理 - 避免移动未完成下载:
- 忽略常见临时扩展名(如
.crdownload、.part、.tmp、.aria2等) - 可选 文件稳定性检测(大小 + 修改时间在 N 秒内不变才移动)
- 忽略常见临时扩展名(如
- 干跑预览(
--dry-run):只打印将执行的操作,不实际移动 - 同名冲突自动处理:自动加
(1)、(2)… 后缀 - 支持写入日志文件(
--log-file)——配合pythonw.exe后台运行尤其推荐
- Python 3.10+(推荐)
- Windows/macOS/Linux
- 依赖:
PyYAMLwatchdog(仅--watch监听模式需要)
git clone https://github.com/<your-username>/Download_Organizer.git
cd Download_OrganizerWindows(PowerShell):
py -m venv .venv
.venv\Scripts\Activate.ps1macOS/Linux:
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txt如果你还没有 requirements.txt,也可以手动安装:
pip install pyyaml watchdog创建配置文件,例如:configs/rules.yaml
示例:
download_dir: "your_path/Downloads"
destination_root: "your_path/Downloads/Sorted"
ignore_extensions:
- ".crdownload"
- ".part"
- ".tmp"
- ".download"
- ".opdownload"
- ".!qB"
- ".aria2"
rules:
- name: "Images"
extensions: [".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp"]
target: "Images"
- name: "Videos"
extensions: [".mp4", ".mkv", ".mov", ".avi", ".webm"]
target: "Videos"
- name: "Documents"
extensions: [".pdf", ".docx", ".doc", ".pptx", ".xlsx", ".md", ".txt"]
target: "Documents"
- name: "Archives"
extensions: [".zip", ".rar", ".7z", ".tar", ".gz"]
target: "Archives"
- name: "Installers"
extensions: [".exe", ".msi"]
target: "Installers"
- name: "CatchAll"
extensions: ["*"]
target: "Others"- 规则从上到下匹配:命中第一条规则就执行
extensions: ["*"]表示兜底规则(建议保留)- Windows 路径建议用正斜杠
C:/...,减少转义问题
预览将要执行的移动操作:
python -m organizer.cli --config configs/rules.yaml --dry-run --verbose确认无误后执行移动:
python -m organizer.cli --config configs/rules.yaml --verbose监听模式(先 dry-run 观察):
python -m organizer.cli --config configs/rules.yaml --watch --dry-run --verbose实际运行:
python -m organizer.cli --config configs/rules.yaml --watch --verbose--stable-seconds:文件必须“稳定不变”的秒数(越大越稳,越小越快)--debounce-seconds:事件防抖(下载器频繁触发变更时建议调大)
示例:
python -m organizer.cli --config configs/rules.yaml --watch --stable-seconds 4 --debounce-seconds 2 --verbosepython -m organizer.cli --config configs/rules.yaml --watch --log-file logs/watcher.log --verbose日志默认追加写入,方便排查问题。
想要“登录后自动运行、且不弹黑色控制台窗口”,推荐用 pythonw.exe:
- 打开 任务计划程序 → 创建任务…
- 常规:
- 选择 仅当用户登录时运行 -(可选)勾选 使用最高权限运行
- 触发器:
- 登录时 -(可选)延迟 30 秒
- 操作 → 启动程序:
- 程序或脚本:
your_path\Download_Organizer\.venv\Scripts\pythonw.exe
- 添加参数:
-m organizer.cli --config "your_path\Download_Organizer\configs\rules.yaml" --watch --log-file "your_path\Download_Organizer\logs\watcher.log" --verbose
- 起始于:
your_path\Download_Organizer
- 程序或脚本:
运行后查看日志:
logs/watcher.log
Download_Organizer/
organizer/
cli.py
config.py
organizer.py
rules.py
utils.py
watch.py
configs/
rules.example.yaml
- 更多匹配条件(文件名正则、大小范围、时间范围等)
- 针对特定浏览器/下载器的“下载完成检测”更深度适配
- 打包成可执行文件(PyInstaller)
- GUI 配置编辑器
欢迎提 Issue / PR。提交 Bug 时建议附上:
- 操作系统与 Python 版本
- 你的配置文件(可删减/脱敏路径)
- 相关日志(建议使用
--log-file输出)