This question is really more for my fellow computer scientists: how does the Put Back feature of the Trash directory work? I'm guessing the OS maintains some sort of index file which stores the path to the current location of the file before moving it to the Trash? Of course, this would be a bit more nuanced with non-empty directories...

Everything that was returned in an admittedly brief Web search had to do with end-user interaction with the Trash. I would like to know how OS X is doing this "under the hood" so that I can emulate the same handling in a script that I am writing.

  • I would expect the original path to be stored in extended attributes on the trashed file. Glance through your ~/.Trash folder with ls -l@ to see some? extended attributes; I forget how to actually look at them, but the Internet can tell you that. Commented Apr 23, 2016 at 2:40
  • 1
    After some more research, it's apparently stored in ~/.Trash/.DS_Store, as per superuser.com/questions/59376/… Commented Apr 23, 2016 at 2:41

1 Answer 1


According to https://superuser.com/questions/59376/how-to-tell-where-an-item-in-the-trash-came-from, "I know the original locations are stored in ~/.Trash/.DS_Store". .DS_Store is the name of the file that stores various Finder-related information.

Following that question, there is also How do I check where the file in .Trash was removed from? and How to determine original location of file that is currently in the Trash?, which don't quite look like duplicates but talk about some of the details a bit more.

  • apple.stackexchange.com/a/184734/76025 might get you a bit closer if you're wanting to dig around. Commented Apr 23, 2016 at 4:54
  • Yeah: running subl ~/.Trash/.DS_Store brings up the file (in my favorite text editor). It's all stored in hexidecimal, though I was hoping it was going to be a series of path strings (for some silly reason). Thanks for pointing me in the right direction.
    – JDQ
    Commented Apr 24, 2016 at 22:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .