This is a small command-line program for OS X that moves files or folders to the trash.
By default, trash asks Finder to move the specified files/folders to the trash instead of calling the system API to do this because of the "put back" feature that only works when trashing files through Finder. If you compile trash by running the command make USE_SYSTEM_API=1 the generated build will always first try the system API and only call on Finder to trash files the user lacks access rights for. See my blog post for more info on some initial implementation details and design decisions.
Usage
Here's the usage info of this program (run it without any arguments to see this):
usage: trash [-ulesv] <file> [<file> ...]
Move files/folders to the trash.
Options to use with <file>:
-v Be verbose (show files as they are trashed, or if
used with the -l option, show additional information
about the trash contents)
Stand-alone options (to use without <file>):
-u Check for updates (and optionally auto-update self)
-l List items currently in the trash (add the -v option
to see additional information)
-e Empty the trash (asks for confirmation)
-s Securely empty the trash (asks for confirmation)
Version 0.8.2
Copyright (c) 2010 Ali Rantakari, http://hasseg.org/trash
Source code is available in a Git repository (click here to show/hide):
Sizes of folders in the trash are now calculated recursively when the -l and -v arguments are used (and we will thus show the total size of the files in the trash).
Dropped PowerPC support in the pre-built binary (I'm now using the XCode 4 dev tools, which do not support PowerPC anymore).
Clarified the use of 'stand-alone' arguments in the usage output.
Fixed bug where symbolic links with a nonexistent target could not be trashed because leaf symlinks would erroneously be followed when determining whether the specified files exist and can be modified.
Changed error message formatting closer to how rm talks.
Implemented auto-update: you can now run trash -u to check for updates and optionally see the release notes and auto-update the program right from the command line.
This version uses Finder for moving all files to the trash by default. This is because of the "put back" feature that doesn't work when using the system API. If you don't care about this feature and want trash to be as fast as possible (the difference is negligible), you can compile a build that uses the system API whenever it can (i.e. whenever the current user has rights to move the specified files) by running the following command in the source directory: make USE_SYSTEM_API=1
Some additional error conditions are now reported to the user via stderr and in the exit status.