OSX: The item XYZ.txt~ can’t be moved to the Trash because it can’t be deleted

I'm trying to delete a file under OSX Lion, but can't. I get the following message:

The item XYZ.txt~ can’t be moved to the Trash because it can’t be deleted.

Here's what I've tried:

  • select file and press COMMAND + DELETE (I get the message above.)
  • renaming the file in finder (There is no option to rename the file.)
  • sudo ls -a in a terminal (The file does not appear.)
  • sudo rm XYZ.txt~ (I get "No such file or directory".)

How do I remove this file?


EDIT

The file went away after restarting. My guess is that it was a glitch in finder.


Solution 1:

Try quitting and reopening Finder.

There is a bug where files that no longer exist are still shown on the desktop (but not if you open a separate window for ~/Desktop/). It has happened to me with .download bundles and with temporary files created by ImageMagick. The files have always disappeared after I have quit and reopened Finder.