Skip to content
forked from sindresorhus/trash

Move files and folders to the trash

License

Notifications You must be signed in to change notification settings

mcanthony/trash

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trash

Move files and folders to the trash

Build Status

Works on OS X, Linux, and Windows.

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 --save trash

Usage

const trash = require('trash');

trash(['unicorn.png', 'rainbow.png']).then(() => {
	console.log('done');
});

Info

On OS X, osx-trash is used.
On Linux, the XDG spec is followed.
On Windows, recycle-bin is used.

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 OS X, you'll lose the Put back feature.

Related

License

MIT © Sindre Sorhus

About

Move files and folders to the trash

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%