Snow Leopard allows users to "Put Back" files that were moved to the Trash from Finder. However, when I do mv <file> ~/.Trash from the command line I don't get the "Put Back" option.

Is there a native command in Snow Leopard that moves a file to the trash while letting me still be able to us "Put Back"?


When you move a file to the trash OS X updates the .DS_Store file inside ~/.Trash with the "Put back" information. (See this question for more details)

In order to update this you would have to also update the .DS_Store file when you move a file to the Trash in Terminal.

  • Thanks. Not what I was hoping for, but it's the truth. – matpie Mar 5 '10 at 21:58

I recommend installing the Ruby gem osx-trash.


sudo gem install osx-trash


Usage: trash [OPTIONS] <file> [<file> ...]
       trash [-e | --empty]
       trash [-l | --list]
Specific options:
    -e, --empty                      Empty the trash
    -l, --list                       List items in the trash
    -h, --help                       Show this message
    -v, --version                    Show version

Manipulate to the Finder's trash.
  • 2
    Nice! Though, as it communicates with Finder, trashing files with a wildcard plays the trashing sound for every file. – Jari Keinänen Mar 20 '11 at 17:59
  • 1
    I don't think this still works. From the docs: osx-trash requires Mac OS X 10.5, Leopard. I tried it and all I get is bash: trash: command not found – yourfriendzak Aug 23 '13 at 2:46
  • Doesnt work on OS X 10.9 asked a fresh question about how to fix it here superuser.com/questions/694433/… – simbo1905 Dec 29 '13 at 9:35

In the MacOSX SDK, there are the functions FSPathMoveObjectToTrashSync and related. It should be easy to write a Python (or whatever) script around it.

Edit: Just coded it. Can be found here: rm-trash.py.

  • FYI - FSPathMoveObjectToTrashSync is deprecated in 10.8 and according to the doc you will need to use trashItemAtURL:resultingItemURL:error: instead. – Lester Cheung Jan 10 '13 at 23:05

You want the rmtrash program.

You can use it to add items to the Trash as if it was done in the finder.

Edit: I just tried using rmtrash to delete and recover. It works exactly like deleting from finder. Files show up in the Trash, can be dragged out and emptied exactly the same. Been using it since '06 or so.

  • From the code of rmtrash, it looks like it is just equivalent to mv file ~/.Trash/. Are you sure that you can recover the files from this tool? – Albert Jun 4 '12 at 19:25

After looking at the alternatives I found out that:

  • The rmtrash program moves files to the trash directory without using the system API, so the .DS_Store file won't be updated. Also, doesn't trigger the recycle sound.
  • The python script invokes a deprecated method on mountain lion which also doesn't trigger the recycle sound.
  • The ruby script works, but is sloooooow (like the python one).

So I wrote my own trash command implemented in the Nimrod programming language, so its fast and it triggers the trashcan sound in a background process. This means that typing the command and running it exits immediately as it doesn't need to wait for the sound to play. The con is you need to compile nimrod and then this program (no binary sorry!).

PS: To be honest the best implementation would be that of rmtrash using the official API I'm using from Nimrod, which is plain objective-c.


Check out trash-cli. It works cross-platform, no trash sound, and supports Put Back.

You can install it with (requires Node.js):

$ npm install --global trash-cli

Alternatively, if you don't want to use Node.js, you can install the native binary osx-trash manually.


I had the same problem today and checked also the rmtrash program given above. Unfortunately all solutions seen so far move files to the home directory's .Trash.

The Finder on the other hand moves it to different -Trash folders, based on the mount point of the filesystem of the file.

So the easiest solution I can come up with (created on 10.5.8. To be tested on newer versions of OS X) is this:

osascript -e 'tell application "Finder" to delete POSIX file "'FULL FILENAME HERE'"'

Here is the shell script I created for it:

declare -a files
for f in "$@" ; do
    if [ -r "$f" ] ; then
        case "$f" in
        /*) ;;
        *) f="$( pwd )/$f" ;;
        files=("${files[@]}" "$f")
        echo "Can't find '$f'" >&2
if [ ${#files[@]} -gt 0 ] ; then
    osascript -e '
    on run argv
        repeat with f in argv
            set x to (POSIX file f) as string
            tell application "Finder" to delete x
    ' "${files[@]}" > /dev/null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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