Tirsvad d86f7712b4
TirSystem/git-workflows: CD / changes (push) Successful in 6s
TirSystem/git-workflows: CI / secret-scan (push) Successful in 8s
TirSystem/git-workflows: CI / validate (push) Successful in 18s
TirSystem/git-workflows: CI / opengrep (push) Successful in 47s
TirSystem/git-workflows: CI / release-check (push) Successful in 5s
TirSystem/git-workflows: CD / wait-for-ci (push) Successful in 1m19s
TirSystem/git-workflows: CD / release (push) Skipped
TirSystem/git-workflows: CD / publish-wiki (push) Skipped
TirSystem/git-workflows: CD / sync-metadata (push) Successful in 5s
TirSystem/git-workflows: CD / sync-milestones (push) Successful in 13s
Merge pull request 'Record the check of the published wiki (RC-015)' (#34) from wiki-published-check into main
2026-11-22 20:45:34 +01:00
2026-11-23 03:42:55 +08:00
2026-11-22 19:54:41 +01:00

🚀 Downloads organiser

A small command line tool that sorts the files of a folder, for example your Downloads folder, into sub-folders by file type. It is a solution to Day 98 (Custom Automation) of the Udemy course "100 Days of Code: The Complete Python Pro Bootcamp", made for fellow course participants and for anyone looking for ideas.

📚 Table of Contents

🧭 Overview

The tool looks at the files directly inside one folder and moves each one into a sub-folder chosen by its extension (Images, Documents, Archives and so on). It is built to be safe:

  • Dry run by default. It prints what it would do and changes nothing until you pass --apply.
  • Undo. Every applied run writes an undo log, and one command moves the files back.
  • No overwriting. If a file with the same name already exists in the target folder, the new file gets a number: photo (1).jpg.

It uses only the Python standard library, so there is nothing to install besides Python itself.

Part What it is for
src/downloads_organiser/ The package: domain (the rules), application (the use cases), infrastructure (file system), presentation (command line), and constants.py (all constants)
tests/ The pytest tests
docs/ Project documents, screenshots and the wiki
Doxyfile Configuration for the Doxygen API documentation

📋 Requirements

  • Python 3.14 or later, to run the tool and the tests.
  • venv, which comes with Python, to keep the tools of this project apart from the rest of your system.
  • Doxygen, only if you want to build the API documentation.

🛠️ Setup

Create a local virtual environment named .venv in the project folder, activate it, upgrade pip and install the project with its test tools.

Windows (PowerShell):

py -3.14 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Linux and macOS:

python3.14 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Leave the environment with deactivate. Delete the .venv folder to remove it; nothing outside the project is changed.

▶️ Run

With the virtual environment active, make a demo folder, look at the plan, apply it and undo it:

downloads-organiser demo demo-downloads
downloads-organiser demo-downloads
downloads-organiser demo-downloads --apply
downloads-organiser undo demo-downloads

Without a folder the tool uses your own Downloads folder, so start with the dry run:

downloads-organiser

The same functions are available from Python, using the names of the assignment:

from downloads_organiser import organise_folder, undo_last_run

organise_folder("demo-downloads")               # dry run: returns the planned moves
organise_folder("demo-downloads", apply=True)   # moves the files
undo_last_run("demo-downloads")                 # moves them back

Folders: Images, Documents, Spreadsheets, Presentations, Archives, Audio, Video, Installers, Code and Other. The rules are in src/downloads_organiser/constants.py. Hidden files, unfinished downloads and sub-folders are left alone.

Lecture steps

The screenshots are made from the real output of the tool by docs/tools/make_screenshots.py. The wiki explains what each step taught, in English, Danish and Bahasa Malaysia.

Step 1: Plan the project

Decide the safety rules first: dry run, undo, never overwrite.

Step 1: Plan the project

Step 2: Set up the environment

A local .venv, an upgraded pip and one pyproject.toml.

Step 2: Set up the environment

Step 3: Keep the rules in constants.py

The table of folders and extensions lives in one place.

Step 3: Keep the rules in constants.py

Step 4: Make a demo folder

Made-up sample files, so no private names are ever shown.

Step 4: Make a demo folder

Step 5: Dry run

The default run prints the plan and changes nothing.

Step 5: Dry run

Step 6: Apply the moves

--apply moves the files and writes the undo log.

Step 6: Apply the moves

Step 7: Undo the run

undo moves every file of the last run back.

Step 7: Undo the run

Step 8: Run the tests

pytest on temporary folders is the safety net.

Step 8: Run the tests

🧪 Tests

With the virtual environment active:

python -m pytest

The code is checked with ruff check, ruff format --check and mypy. The API documentation is built with doxygen Doxyfile and written to docs/doxygen/html.

Security scan

Before every push the repository is scanned with opengrep (the pull request check runs the same tool with the organisation rule set):

& "$HOME\.opengrep\cli\latest\opengrep.exe" scan --config auto --exclude framework --error .

📄 License

The project is licensed under the GNU Affero General Public License version 3, see LICENSE.

📎 Appendix: Project documents

The documents a newcomer needs, in reading order.

Document What it tells you
Business Case Why the project exists, its scope and success criteria
Stakeholder Analysis Who is involved; the stakeholder IDs used for owners and reviewers
Project Plan The gateways and their schedule
Milestones One document per gateway: Go/No-Go criteria and tasks
Artifact registry Where each artifact type lives, the next version, the PO language and domain
Framework README The framework this project uses

S
Description
Downloads organiser: a dependency-free Python command line tool that sorts files into folders by type, with dry run and undo. Udemy 100 Days of Code, Day 98 assignment: Custom Automation.
Readme AGPL-3.0
518 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 100%