Discussion:
Move to Windows Recycle Bin instead of deleting
Ralf Hauser
2003-01-14 19:42:45 UTC
Permalink
Is there a way to have the files moved to the windows recycle bin from
the cygwin shell window/command line?
Igor Pechtchanski
2003-01-14 21:05:35 UTC
Permalink
Post by Ralf Hauser
Is there a way to have the files moved to the windows recycle bin from
the cygwin shell window/command line?
Yes. In your ~/.bashrc:

RECYCLE_BIN_PATH="<location of your recycle bin>"
function rm() { mv "$@" "$RECYCLE_BIN_PATH" }

The one gotcha of the above is that "mv" will get the options passed to
"rm" - not sure if there are any discrepancies. However, if you stick to
"rm -r" and "rm -f", you should be fine.

The procedure for finding the location of the recycle bin depends on your
operating system and your setup. On my Win2k machine, I can simply use

RECYCLE_BIN_PATH="/cygdrive/c/RECYCLER/`ls -t /cygdrive/c/RECYCLER|head -1`"

Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ ***@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ ***@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
-- /usr/games/fortune
Rolf Campbell
2003-01-14 21:17:03 UTC
Permalink
-----Original Message-----
Sent: Tuesday, January 14, 2003 4:06 PM
To: Ralf Hauser
Subject: Re: Move to Windows Recycle Bin instead of deleting
Post by Ralf Hauser
Is there a way to have the files moved to the windows
recycle bin from
Post by Ralf Hauser
the cygwin shell window/command line?
RECYCLE_BIN_PATH="<location of your recycle bin>"
I would speculate that another problem with this is that if you view the
recycling bin in explorer, then you will no see (or be able to restore)
the cygwin files. Also, if you empty the bin using explorer, then you
will likely leave all cygwin-moved files.

-Rolf
Chris Polley
2003-01-14 22:26:02 UTC
Permalink
Post by Ralf Hauser
Is there a way to have the files moved to the windows recycle bin from
the cygwin shell window/command line?
AFAIK, there isn't, although the
int SHFileOperation(LPSHFILEOPSTRUCT lpFileOp) function in
shell32.dll

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shfileoperation.asp>

might be useful in working out a way to do it.

HTH,
CHris
Igor Pechtchanski
2003-01-14 22:39:52 UTC
Permalink
Ralf,

Please keep the discussion on the list so other people have access to this
information and opportunity to share their experience. That "Reply-To:"
is there for a reason.

It's quite possible that something like this would happen. It makes sense
that some sort of versioning is used for the deleted files. There might
also be a difference between recycle bins on NTFS and FAT32 filesystems.

I should probably have added a disclaimer that the script below is
untested, as I, myself, don't use this kind of trick. The next place to
look would probably be MSDN (<http://msdn.microsoft.com/>)... You might
even need to resort to using rundll32 and calling a function that erases
the file.

I'm sorry I can't be of more help.
Igor
P.S. I don't know Michael Steiner, sorry.
Igor,
Thanks for the hint.
My win2k doesn't know /cygdrive/c/RECYCLER/ but /cygdrive/c/Recycled
When just moving to the latter, it gets there and can be seen via cygwin
command line "ls" (I just see the correct extension, but not the filename -
it comes like "Dc712".html), but when opening the windows recycle bin icon,
I don't see it.
Doing that "ls -t ... | head -1" yields INFO2 to me and that appears to be a
binary info file about where the files were deleted from and when.
Trying to redo your RECYCLE_BIN_PATH got me slightly into trouble because
when I copied a test file to
/cygdrive/c/RECYCLER/INFO2 going back to the windows representation of the
Recycle bin, all information was wiped and it claims to only contain 0 files
while under cygwin's "ls", still all the D###.* files are there.
Right-mouse-click refresh unfortunately doesn't help.
Any thoughts?
Ralf
P.S.: Don't worry I don't think anything I desperately want to recover was
in my recycle bin...
P.P.S.: Say hello to Michael Steiner he just started to work at Watson
too...
-----Original Message-----
Sent: Dienstag, 14. Januar 2003 22:06
To: Ralf Hauser
Subject: Re: Move to Windows Recycle Bin instead of deleting
Post by Ralf Hauser
Is there a way to have the files moved to the windows recycle bin from
the cygwin shell window/command line?
RECYCLE_BIN_PATH="<location of your recycle bin>"
The one gotcha of the above is that "mv" will get the options passed to
"rm" - not sure if there are any discrepancies. However, if you stick to
"rm -r" and "rm -f", you should be fine.
The procedure for finding the location of the recycle bin depends on your
operating system and your setup. On my Win2k machine, I can simply use
RECYCLE_BIN_PATH="/cygdrive/c/RECYCLER/`ls -t
/cygdrive/c/RECYCLER|head -1`"
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ ***@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ ***@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
-- /usr/games/fortune
Tino Lange
2003-01-15 08:34:30 UTC
Permalink
Post by Ralf Hauser
Is there a way to have the files moved to the windows recycle bin from
the cygwin shell window/command line?
Hi!

You can use the freeware "Delete XP"
http://www.easytools.com/Downloads/Freebies/
which behaves like the standard (MS) "del" - but deletes to the recycle
bin. I use it for years (it was formerly known as "Delete 97") without
problems.

Cheers

Tino

Continue reading on narkive:
Loading...