How can we insert multiple objects with the same name into the Windows Recycle Bin?

5

1

I want to understand why objects in the Recycle Bin don't need to be renamed when two or more objects have same name. In other places, two objects cannot have the same name: we are forced to rename them.

Hamid

Posted 2013-07-01T12:18:28.193

Reputation: 185

Question was closed 2013-07-01T16:26:01.773

@ta.speot.is,OK.but i can't see that in my search.BTW tnx. – Hamid – 2013-07-01T12:22:59.470

@ta.speot.is: I've renamed the question to How does the Recycle Bin work?

– bwDraco – 2013-07-01T14:32:26.200

Answers

12

Contrary to @tikend, files are not saved in their old path and just marked as deleted. Instead, files are moved to the $Recycle.Bin directory at the root of drive. Inside, there are folders named something like S-1-5-21-4284498480-1431815607-1764836822-1001 (actual example)*, and inside those are the deleted files.

Why we can have two files with same name in Trash? Because their names are mangled. Instead of sumthinFunny.cpp we have $RYDITY2.cpp. Those identifiers make it possible to have two files with the same name.

How does Windows know where the file was deleted from? It stores the file’s metadata (like path in question, file attributes, and so on) in the $IYDITY2.cpp file. Inside, there is path to the original directory.

By the way, if you open $Recycle.Bin from Windows Explorer, it appears empty. You can see it if you mount drive from Linux, or through a other file manager, like Total Commander.

BTW2: While file names are mangled into $RYDITY2.cpp like form, when you open their properties, you get something that looks like UUID:

i.imgur.com/oA8rziH.png

* This folder name is the SID of the user who deleted the file.

Edited in order to bring comments' wisdom here.

Szymon Szydełko

Posted 2013-07-01T12:18:28.193

Reputation: 418

1Yeah, I mixed it with something else, they relative path is stored in recycle bin thou, so they can be restored. – tikend – 2013-07-01T12:26:59.750

1@Szymon Szydelko , Thank you for your answer.it should be up vote! – Hamid – 2013-07-01T12:29:38.487

1AFAIK relative path is stored either as resource fork, xattr, somewhere in %windir% or in registry. Why? Because structure of mentioned folder is flat eg. there are no Users, Program Files and so on directories. However, if you delete whole direcrory, is is moved there like it would be one file, with filenames inside unmangled! – Szymon Szydełko – 2013-07-01T12:31:49.483

More facts! While file names are mangled into $RYDITY2.cpp like form, when you open their properties, you get something that looks like UUID: http://i.imgur.com/oA8rziH.png

– Szymon Szydełko – 2013-07-01T13:17:06.947

1The folder names are the SIDs of the users who have deleted files. As well as the $R.. files there are corresponding $I.. files which contain metadata for the deleted files, including the original name. You can see inside $Recycle.bin if you are an administrator and turn of both file hiding parameters. – David Marshall – 2013-07-01T13:17:11.213