11

I couldn't find any info regarding this question.

Is there even a way for node.js to send a file / folder to bin instead of fs.unlink / fs.rmdir?

For example:

Can you do something like sendToBin(path) to send a file to recycle bin (Windows) trash (MacOS) instead of running fs.unlink() to remove file from disk (I know that it just marks it with 0)

9
  • Please explain your question in more detail. Commented May 15, 2018 at 12:23
  • @zero298 I mean. That's all there is to explain. can you do something like fs.sendToBin(path) instead of fs.unlink(path)? Commented May 15, 2018 at 12:25
  • 1
    bin means Trash ? Commented May 15, 2018 at 12:26
  • What is fs.sendToBin() supposed to do? Commented May 15, 2018 at 12:26
  • 3
    try this github.com/sindresorhus/trash Commented May 15, 2018 at 12:29

2 Answers 2

13

Node.js's fs doesn't provide any api for moving files to Trash/Recycle Bin, but you can try trash node-module to have work-around.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, now at least 1 result will pop up when you search "node.js send file to bin instead of deleting from disk permanently" in Google. Literally spent 10 minutes trying to find anything, turns out I had to use the word "trash" (MacOS) instead of "bin" (Windows)
3

Updated 2024: You can use shell.trashItem(path) for moving files to Trash/Recycle Bin

const { shell } = require('electron') shell.trashItem(path) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.