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).jpg00$ ./large (26).jpg00$ ./large (2).jpg00$ ./large (5).jpg00$
The filesystem is NTFS.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
chkdskin Windows.
Apparently, and happily, this has solved your issue.
Method 2
Try:
rm -i large*.jpg
This will ask you whether to delete every matching file. Say “no” for all the files other than this one.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0