Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrash-0.4.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytrash-0.4.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file pytrash-0.4.0.tar.gz.

File metadata

  • Download URL: pytrash-0.4.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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

Hashes for pytrash-0.4.0.tar.gz
Algorithm Hash digest
SHA256 74557aa6f021e8ed11aea46b6489320cc8113a04a91fcbaaaf70f0473c524682
MD5 f827ddd4caa4d0e86f630be21b305763
BLAKE2b-256 ea0af4eb4cef6b1a81bf733f6735a2aed653573fce1255e3d2187eddb3cf104b

See more details on using hashes here.

File details

Details for the file pytrash-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pytrash-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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

Hashes for pytrash-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 110ecdca262f2019b775bffdf7fd4d89c4975886f17c633ffb00f00c5623298f
MD5 cfce56937c40e4753b890a64085d79af
BLAKE2b-256 53b49ba255785cd8fd4b87c03c4d7f5cbd2863f059bc32e77b7d5a5a6f0b8b2d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page