When you try to empty the Trash in OS X, and there is a file still open in an application, you receive the dialog:
The operation can't be completed because the item "…" is in use.
How can I find out which application or which process still uses this file?
Best Answer
Using
lsof
to find what's keeping the file openOpen up Terminal.app and use the following command to get to your Trash:
Now, enter the following command:
For example, in the above screenshot, it would be:
lsof pdf\ 08-53-59.pdf
(important to escape spaces here). You can also just enterlsof
with a space afterwards, and then drag the file from Finder's Trash into the Terminal window.The command will output something like the following:
In that case, we know that Finder is keeping the file open. For any other application, it would be easy to just activate and quit it. In case of the Finder, there's no obvious "quit" button.
To kill the Finder and release the document, just enter the following in the Terminal:
You should now be able to empty your Trash.
Other tricks
If the above does not succeed, here are some very basic tricks you can try to empty your trash: