a high level api for handling recycle bins across platforms
Project description
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"])
# 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytrash-0.3.4.tar.gz.
File metadata
- Download URL: pytrash-0.3.4.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e57aa199422c54e7343e29a6c24fcda4c040f44409cc008a213ad3a9d9b93cc
|
|
| MD5 |
965e90e289cd11a345d139116525b11d
|
|
| BLAKE2b-256 |
bbb097ef2bf739b1f58a42ae44332a7a7a1f42ccd074dd8f9358cabb7c1006b1
|
File details
Details for the file pytrash-0.3.4-py3-none-any.whl.
File metadata
- Download URL: pytrash-0.3.4-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3bb0823af0b093169ba169d036620d214934b4dc5c86758ad363aa3e1322188
|
|
| MD5 |
0bac8ce431a248ddfde8058fd0071601
|
|
| BLAKE2b-256 |
4c2a71a2dbc69b37ce3e4d6c0fe84529322d7c24085dae470dee921dd51acc60
|