5

I use delete-by-moving-to-trash to move deleted files and folders into trash instead of deleting them. However, if the file or folder with the same name is already in Trash I get an error file already exists".

On macOS and while I delete file using Finder which name already exists in the Trash it adds current timestamp to the deleted file name to differentiate it. For example foo become foo 20.28.19.

Is there a way achieve the same in Emacs?

That would solve the problem, but I'm also open for other solutions if they exists.

1 Answer 1

4

You can use the Finder to move the files with the following function

(defun system-move-file-to-trash (filename)
  "Move file or directory named FILENAME to the trash."
    (ns-do-applescript
     (format
      "tell application \"Finder\" to delete POSIX file \"%s\""
      filename)))

Not tested on recent Mac OS versions.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.