sindresorhus/trash has 2,666 GitHub stars and 82 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-05 23:13 UTC. Last push 2026-09-18.
Move files and directories to the trash
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalMove files and folders to the trash
Works on macOS (10.12+), Linux, and Windows (8+).
Note: The Linux implementation is not very good and not maintained. Help welcome. If no one steps up to help maintain it, I will eventually remove Linux support.
In contrast to fs.unlink, del, and rimraf which permanently delete files, this only moves them to the trash, which is much safer and reversible.
Install
npm install trash
Usage
import trash from 'trash';
await trash(['*.png', '!rainbow.png']);
API
trash(input, options?)
Returns a Promise.
input
Type: string | string[]
Accepts paths and glob patterns.
Non-existent files and glob patterns that match nothing are silently ignored. If you need to know whether files were actually trashed, check for their existence beforehand.
options
Type: object
glob
Type: boolean
Default: true
Enable globbing when matching file paths.
CLI
To install the trash command, run:
npm install --global trash-cli
Info
On macOS, macos-trash is used.
On Linux, the XDG spec is followed.
On Windows, recycle-bin is used.
On WSL (Windows Subsystem for Linux), files are moved to the Windows Recycle Bin.
FAQ
But I can do the same thing with mv
Not really. The mv command isn't cross-platform and moving to trash is not just about moving the file to a "trash" directory. On all OSes you'll run into file conflicts. The user won't easily be able to restore the file. It won't work on an external drive. The trash directory location varies between Windows versions. For Linux, there's a whole spec you need to follow. On macOS, you'll lose the Put back feature.
Windows service account behavior
When running as the Windows SYSTEM account or other service accounts, files are moved to that account's recycle bin (e.g., C:\$Recycle.Bin\S-1-5-18\ for SYSTEM). These files won't be visible in the normal user's recycle bin and may accumulate over time. For service contexts, consider using direct file deletion instead.
Related
- trash-cli - CLI for this module
- empty-trash - Empty the trash
- del - Delete files and folders
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,362 starspublic-apis/public-apis
A collective list of free APIs
496,655 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
437,324 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,047 stars