delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/05/14/08:19:17

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
X-IronPortListener: Outbound_SMTP
MIME-Version: 1.0
Subject: RE: Feature request: rm to recycle bin
Date: Wed, 14 May 2008 08:18:40 -0400
Message-ID: <31DDB7BE4BF41D4888D41709C476B6570929AF35@NIHCESMLBX5.nih.gov>
In-Reply-To: <48258BCC.9090905@sdkennedy.com>
References: <48258BCC DOT 9090905 AT sdkennedy DOT com>
From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder AT niaid DOT nih DOT gov>
To: <cygwin AT cygwin DOT com>, <steve AT sdkennedy DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id m4ECJFnl028335

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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019