Ever had Finder say "The operation cannot be completed because the item "foo.txt" is in use", when you try and empty the Trash?
Except you look at all your apps and NONE of them appear to have "foo.txt" open?
Just open Terminal,
type "lsof " (notice the trailing space)
open the Trash window by clicking on the Trash icon in the Dock.
Drag the "foo.txt" or whichever item is "stuck" into the Terminal window.
Hit return. lsof will tell you which process has the file open. You can then quit that app to release the file (even though the app itself claims that it doesn't have the file open).
Here is some sample output for "stuck open" file "1148.pdf" which I opened in Preview and then trashed the file while Preview had it open:
Under "COMMAND" above, lsof tells us that the file in question is opened by the process "Preview". Voila.
I think this could be made into a script that would take ALL items in the Trash and list which apps have them open. I'm working on it.
Except you look at all your apps and NONE of them appear to have "foo.txt" open?
Just open Terminal,
type "lsof " (notice the trailing space)
open the Trash window by clicking on the Trash icon in the Dock.
Drag the "foo.txt" or whichever item is "stuck" into the Terminal window.
Hit return. lsof will tell you which process has the file open. You can then quit that app to release the file (even though the app itself claims that it doesn't have the file open).
Here is some sample output for "stuck open" file "1148.pdf" which I opened in Preview and then trashed the file while Preview had it open:
Code:
Dual-G5:~/Desktop lundy$ lsof /Users/lundy/.Trash/1148.pdf
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Preview 7639 lundy txt VREG 14,3 136144 1162021 /Users/lundy/.Trash/1148.pdf
Dual-G5:~/Desktop lundy$
Under "COMMAND" above, lsof tells us that the file in question is opened by the process "Preview". Voila.
I think this could be made into a script that would take ALL items in the Trash and list which apps have them open. I'm working on it.
--Johnny
--Johnny








