How do you know where items in the Trash came from?

I have a lot of items in the Trash. I would like to determine where these items were before they were discarded.

MacBook Air 13″, macOS 11.3

Posted on Aug 19, 2023 4:02 PM

Reply
13 replies

Aug 21, 2023 1:15 PM in response to jjjefff

jjjefff wrote:

This is interesting...I have a lot of files in my Trash. Some files have "Put Back" and some do not. I'm not sure why they differ.

You've probably deleted the directory it was originally in. In that case, you really can't put it back because there is no place for it to go.


The bottom line here is that the trash is the trash. Once something is there, it's a bit late to start your review of whether it should be there. It's not absolutely too late. You can drag things out of the trash. In many cases, you can simply change your mind and put the items back. But once you reach the point where you effectively have a trash filing system, then you've gone beyond its designed functionality. Bummer to be you.


Your options:

1) Empty the trash

2) Put back what you can and #3 or #4 the rest

3) Drag the items out of the trash, re-organize them, and move them somewhere else

4) Write a parser for DS_Store using something more powerful than sed. Use that to recreate the original file system and restore all the files back to where they originally lived. Note that nothing about the DS_Store file was ever documented by Apple. If you weren't already a software developer, you'll be able to claim the title when you're finished.


I recommend #3. Obviously you put them in the trash for a reason. It sounds like you no longer trust your reasoning. OK. Fair enough. Review the files and in the case of any doubt, move the file to some new location that seems appropriate.

Aug 21, 2023 9:32 AM in response to etresoft

Or, from your linked entry, the following Terminal syntax, tailored to the user's Trash folder, with an additional Perl regex to reduce the output to just the original file locations:


xxd -p ~/.Trash/.DS_Store | sed 's/00//g' | tr -d '\n' | sed 's/\([0-9A-F]\{2\}\)/0x\1 /g' | xxd -r -p | strings | sed 's/ptb[LN]ustr//g' | perl -lne 'print "$2$1" if $_ =~ /(.*)\)(.*$)/;'
System/Volumes/Data/Users/viking/Desktop/kant_jacobian copy 2.docx
System/Volumes/Data/Users/viking/Desktop/kant_jacobian copy 3.docx
System/Volumes/Data/Users/viking/Desktop/kant_jacobian copy.docx


Tested: Ventura 13.5.1


"It's complicated" remains an understatement… 🤓



Aug 20, 2023 2:26 AM in response to jjjefff

Has the user every attached and external Drive to this machine ?


Has the user every deleted files from that external Drive ?


As the User forgotten to Empty the Trash ( Bin ) before dismounting the External Drive ?


Once that Exact Some External Drive is re-attached to the Computuer - the Trash (Bin ) would appear with those previously Deleted Files



Aug 21, 2023 2:33 PM in response to jjjefff

jjjefff wrote:

The search feature does not find *any* DS_store files.

I don't know what you mean about a "search feature". The vast majority of files in the operating system, especially those DS_Store files are hidden from virtually all "searches". I only included that link as a demonstration of how complicated this is. I probably shouldn't have even done that. Those kinds of things can give people false impressions. For example, "the Trash" is not a folder. It is a "Finder artifact". It doesn't really exist. You may accidentally stumble upon some partial implementation detail like a hidden ".Trash" directory in your home directory. But that's not the the trash. That's a partial implementation detail. It's much more complicated than that.

Aug 21, 2023 11:37 AM in response to jjjefff

This is based on my moving three files to my Trash from the Desktop with Finder several minutes before I ran the Terminal command from my home directory. That gave Finder time to create the hidden .DS_Store in my Trash folder. I also have Full Disk Access permissions for the Terminal set in my System Settings : Privacy and Security panel.


I continue to agree with etresoft that this is no way to run a railroad…

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do you know where items in the Trash came from?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.