pytrash
a high level api for handling recycle bins across platforms
Installation
uv add pytrash
Usage
import pytrash
# pytrash provides a way to move files to the bin, list entries in bin, and restore files from bin.
# create instance of Bin
bin = pytrash.RecycleBin()
# move a file to the bin
bin.recycle(["path/to/file.txt"])
# recycle and keep entries to restore these exact items later
recycled = pytrash.recycle(["path/to/another.txt"], return_entries=True)
pytrash.restore(recycled)
# bin.recycle(..., return_entries=True) works the same way
# list entries
bin.entries()
# restore a file from the bin
entry = bin.entries()[0]
bin.restore([entry])
# permanently delete a file from the bin (irreversible!)
bin.purge([entry])
# permanently delete everything in the bin (irreversible!)
bin.empty()
That's it. It doesn't get any simpler than that.
Entries are returned as a list of TrashEntry dataclasses, which contain the following attributes:
TrashEntry(
name='Screenshot from 2026-06-10 17-35-55.png',
original_path='/home/nspc911/Pictures/Screenshots/Screenshot from 2026-06-10 17-35-55.png', # this will be None if entry doesn't contain this info
deleted_at=datetime.datetime(2026, 6, 28, 11, 31, 17), # this can be None if entry doesn't contain this info
size=13075 # shouldn't be None, but it is possible.
)
For now, only the major 3 OSes are supported (Windows, Linux, MacOS). If you want to add support for your OS, feel free to open a PR.
CLI
This also includes a CLI for interacting with the recycle bin
uv tool install pytrash
pytrash trash <file1> <file2> ... # move files to the bin
pytrash list # list entries in the bin
pytrash list --json # list entries in the bin
pytrash restore <entry1> <entry2> ... # restore entries from the bin
pytrash purge <entry1> <entry2> ... # permanently delete entries (asks first; -y to skip)
pytrash empty # permanently delete everything (asks first; -y to skip)
This CLI interface is not to be compared with the trashy CLI, it is Rust, it doesn't have the Python Interpreter overhead. This project aims to provide an easy interface for cross platform bins. The CLI is simply a way to make use of it.
Like what I do? Check out similar projects
- multiarchive: a high level api for handling archives across formats
Metadata
Release files for pytrash 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytrash-0.5.0.tar.gz | 19.0 kB | Without provenance | Details for pytrash-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytrash-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pytrash-0.5.0-py3-none-any.whl |
Total release size: 41.7 kB
Release files / pytrash-0.5.0.tar.gz
| Download URL | pytrash-0.5.0.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d76a18430d67b45cc1d0eb9132db1cdafa1cdb055bc858da0b696095e2a1245
|
|
BLAKE2b-256 checksum How to use checksums |
bd29fc6bc993281e02967da4bb989446b3db384f5582c457dc5ecf81361b011e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pytrash-0.5.0-py3-none-any.whl
| Download URL | pytrash-0.5.0-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c38e7dcf7bdcc6025b2412e68898dda28d6ee8a50d5ec8ff81d91184f4ca682
|
|
BLAKE2b-256 checksum How to use checksums |
af75f8d6714140cd78178c6c0d0304c2caaf701c017310dce3ec70e96101cead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pytrash 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.