Files stuck in the Bin (Trash)

I deleted Plex a while ago from my Mac Mini running raw version of macOS before Catalina. I thank searched for any files which had Plex in the name and deleted those too.

After trying to empty the bin, I’ve ended up with a file in a number of folders which cannot be deleted. Emptying the bin or doing a secure empty doesn’t work either.

The error message I get is “This operation can’t be completed because the item [massive long string of numbers and letters]‘bundle is in use with options to Skip, Stop or Continue

The named file zero bytes and if I open the backage it is blank (no files)

The bundle is in test\users\geoffairey\library\application support\Plex media server\metadata\tv shows\b\

Is there any way for me to find out what is locking this file?

Thank you.

Try rebooting and then emptying the trash.

Thanks Jec, that was one of the first things I tried.

Have you tried “rm” in Terminal?

You can Force-Quit in Terminal

Here is what I would do.

  1. Open the Trash

  2. Move all files from Trash to some folder in /tmp/ such as /tmp/trash/ (you’ll have to create that /tmp/trash/ folder first)

  3. Reboot

Now, you could do that in Finder, or you could do it in the Terminal.

In the Terminal, it would look like this


mkdir /tmp/trash

find ~/.Trash -mindepth 1 -maxdepth 1 -exec mv -vf {} '/tmp/trash/' \;

Then reboot as usual.

Why try this? Because /tmp/ is normally emptied out by rebooting.

Will it work? Should. Check to see if /tmp/test/ exists after rebooting to see.

“What do those shell/Terminal commands do?”

mkdir /tmp/trash

mkdir means make directory so this will make a directory (aka folder) at /tmp/trash

The find command is made up of several parts, so let’s look at each one. As a reminder, here’s the full command:

find ~/.Trash -mindepth 1 -maxdepth 1 -exec mv -vf {} '/tmp/test/' \;

  1. find ~/.Trash means that we want to look in the trash folder, which is in your home directory (~) and is named .Trash

  2. -mindepth 1 means we want to match things _inside ~/.Trash/ but not ~/.Trash/ itself (so we don’t end up trashing out trash folder itself)

  3. -maxdepth 1 means we don’t want to go into any folders inside ~/.Trash/ because all we need is the folders themselves, not their contents.

  4. -exec mv -vf {} '/tmp/test/' is a bit trickier, so I’ll break it down further:

    • -exec means “run the command I’m about to give you”

    • mv -vf says “move the files [v]erbosely and [f]orce them to move, overwriting any files that already exist there” (which there shouldn’t be in this case, but still)

    • {} is how you tell find command “anything that matches the find command? Put that here”

    • /tmp/test/ is just the name of the folder for the mv/move command

    • \; says “OK, this is the end of the -exec command I started earlier.”

HTH

–TJ

1 Like

Thanks @tjluoma , I appreciate the explanation.

Unfortunately on the second line I get “Operation not permitted”

I’m assuming that the /tmp/test/ should have been /tmp/trash/ but neither works

I can cd into the /tmp/trash folder, but an ls shows me nothing (as it should)

I moved the file with finder, but a reboot didn’t delete the file unfortunately.

Have you tried CleanMyMac? It got rid of files stuck in my Trash several times.

Originally you asked if there was any way to see what is using that file, maybe knowing that would yield a clue. The terminal command for that would be

lsof | grep filename

substituting the actual filename for filename. The character between “lsof” and “grep” is the pipe symbol, a vertical bar.

Ok, try these two commands.

First this one:

sudo find ~/.Trash -mindepth 1 -maxdepth 1 -exec chflags noschg {} \;

Then this one:

sudo find ~/.Trash -mindepth 1 -maxdepth 1 -exec chflags nouchg {} \;

Then try emptying the trash as usual.

After the first sudo command, you may be asked to enter your login password for your Mac.

You should only need to enter it once. It won’t appear on the screen when you enter it, for security.