NTFS File Deletion Error – Fixing ‘No Such File or Directory’ Message on NTFS

filesntfsrm

I have a directory with images. Suddenly I found out that there's a new image with a new name. The image content is similar to another image in another directory but with a different name. I didn't copy this image to this directory.

Also a directory with the same name as the image suddenly appeared there. I didn't create any of them. When I tried to delete them I got this message "No such file or directory" even though it already existed there. I used the command sudo rm -rf imagename.jpg to delete it but it didn't work.

Can anyone explain why this is happening and how to solve it?

The output of ls -l "large (2).jpg":

-rw------- 1 alaa alaa 2859942 Jun  8 04:01 large (2).jpg

The output of rm "large (2).jpg":

rm: cannot remove ‘large (2).jpg’: No such file or directory

The output of printf %s\\0\\n ./large* | sed -n l

./large (20).jpg\000$
./large (26).jpg\000$
./large (2).jpg\000$
./large (5).jpg\000$

The filesystem is NTFS.

Best Answer

I once posted a pretty in-depth look at NTFS file-streams as related to the linux ntfs-3g driver due to a similar issue on a different question. I remembered it, and - guessing that your problem was also on an NTFS partition - I posted this comment here:

If it's NTFS I suspect this. This can occur if a file's basic permissions are modified as you end up affecting the stream. I think that's what happens. It's complicated - and probably at least a little beyond me. But it happens. Anyway, run chkdsk in Windows.

Apparently, and happily, this has solved your issue.

Related Question