Stephen Kennedy wrote on Saturday, May 10, 2008 7:50 AM:

> I've searched the mailing list so believe this isn't a FAQ; apologies
> if it is. 
> 
> There have been several threads on the mailing list about replicating
> Windows' recycle bin functionality using aliases or shell functions,
> none of which are really satisfactory. However, in this thread
> http://sourceware.org/ml/cygwin/2007-01/msg00327.html it was
> discussed that 'rm' has been patched to send deleted files to the
> recycle bin in certain limited circumstances.     
> 
> Given that the code for sending to recycle bin is already in place,
> may I request that a command line option be added to rm and rmdir to
> send all files to the bin? This would be extremely handy for use in
> scripts, to me at the very least.   
> 
> While I'm here please let me thank you very much for providing such an
> *awesome* set of tools.
> 
> Steve

What you might consider is finding a Windows command line utility that
does what you want and put a cygwin wrapper around it.  One that I know
of can be found here: <http://www.maddogsw.com/cmdutils/>.  NOTE:  I do
not actually use <recycle.exe>, so this is a suggestion, not a
recommendation.  Note also that this utility is GPLed (ver. 2).

This wrapper should work.  (Again, not tested.)  I make no
representation that it is bug-free.

        #!/bin/sh
        if [ "$1" = '--help' -o $# = 0 ]
        then
                echo Usage: $(realpath "$0") [OPTION]... FILE...
                echo Send the FILE(s) to the Windows Recycle Bin.
                echo '  -i      prompt before every removal'
                echo '  --help  display this help and exit'
                exit
        fi
        FORCE='-f'
        if [ "$1" = '-i' ]
        then
                FORCE=''
                shift
        fi
        for F in $@
        do
                if [ -f "$F" ]
                then
                        path/recycle ${FORCE} "$(cygpath -w "$F")"
                else
                        echo $(basename "$0": \`$F\' not found.
                fi
        done

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to