Files Won't Delete From Directory

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
metamorphousthe
Level 2
Level 2
Posts: 86
Joined: Fri Sep 19, 2008 6:55 am

Files Won't Delete From Directory

Post by metamorphousthe »

I am not sure whether this Topic belongs here in Software & Applications or Desktop & Window Managers.

LM 19.3 Cinn 64b

A directory of mine under my user name shows a few custom text files that cannot be deleted or moved from within nemo, nor in terminal under me or sudo. These are text files I created at one time (but now no longer need) on my external drive. These files are 0 (zero) bytes in size.

I see the files in nemo and also in terminal using ls to show contents of the directory.

a sample command:
sudo rm {file}*
rm: cannot remove '{file}': No such file or directory

I have made sure that my external and internal drive's trash bins are empty of contents
external drive = .Trash-1000 & $RECYCLE.BIN
internal drive = my .local/Share's Trash

These same problem files are also seen when browsing directory contents using nautilus.

Are there any other places to dump contents? What are some next steps? How do I get rid of these lingering files? Is there a nemo cache someplace that needs to be dumped?
metamorphousthe
"It's all about change"
User avatar
Flemur
Level 19
Level 19
Posts: 9051
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Files Won't Delete From Directory

Post by Flemur »

metamorphousthe wrote:
Fri Mar 20, 2020 5:43 pm
a sample command:
sudo rm {file}*
rm: cannot remove '{file}': No such file or directory
That means you have the filename wrong. How about posting the result of

Code: Select all

ls -al {file}*
using the real filenames.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
metamorphousthe
Level 2
Level 2
Posts: 86
Joined: Fri Sep 19, 2008 6:55 am

Re: Files Won't Delete From Directory

Post by metamorphousthe »

Code: Select all

$ ls -al
total 116
drwxrwxrwx   1 {user} {user} 102400 Mar 20 19:10  .
drwxrwxrwx   1 {user} {user}  16384 Dec 19 04:21  ..
-rwxrwxrwx   1 {user} {user}      0 Jul 20  2019 'Colony S01E05'
-rwxrwxrwx 556 {user} {user}      0 Jul 20  2019 'Impulse S02E01'
-rwxrwxrwx   1 {user} {user}      0 Jul 19  2019 'Prestonwood 191019 HELP! The God of All Comfort.mp4'
metamorphousthe
"It's all about change"
User avatar
Flemur
Level 19
Level 19
Posts: 9051
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Files Won't Delete From Directory

Post by Flemur »

metamorphousthe wrote:
Fri Mar 20, 2020 7:12 pm

Code: Select all

$ ls -al
Nope, that's not

Code: Select all

ls -al {file}*
using the real filenames, as I mentioned.

If you want to delete those files but can't type the names correctly, try this:

Code: Select all

rm *
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
metamorphousthe
Level 2
Level 2
Posts: 86
Joined: Fri Sep 19, 2008 6:55 am

Re: Files Won't Delete From Directory

Post by metamorphousthe »

I think I understand what you mean now.

The file name has multiple words separated by a SPACE which won't work name-wise in terminal?
metamorphousthe
"It's all about change"
User avatar
Flemur
Level 19
Level 19
Posts: 9051
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Files Won't Delete From Directory

Post by Flemur »

metamorphousthe wrote:
Fri Mar 20, 2020 10:59 pm
I think I understand what you mean now.
The file name has multiple words separated by a SPACE which won't work name-wise in terminal?
Yup. Spaces are bad news (but see below), you should probably replace them with _ (underscore) or - (minus).

If you tried:
rm Colony S01E05
it should treat those as two files, both not found; that's why I wanted you to type
ls Colony S01E05
and ls would also not find them.

But these commands would work: put quotes around the name, or 'escape' the spaces, or use *:

Code: Select all

rm "Colony S01E05"
rm Colony\ S01E05
rm Col*
But spaces or other delimiters in file names are still liable to cause funny problems at funny times.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Kester
Level 4
Level 4
Posts: 387
Joined: Sat Apr 30, 2016 3:05 pm

Re: Files Won't Delete From Directory

Post by Kester »

Hi,

An unorthodox method that will probably be frowned upon by the experts, but which I have used with success when I have had similar problems, is to boot your system with live Puppy Linux media. Now access the directory containing those reluctant to go files, highlight them and delete them in the conventional way.
metamorphousthe
Level 2
Level 2
Posts: 86
Joined: Fri Sep 19, 2008 6:55 am

Re: Files Won't Delete From Directory

Post by metamorphousthe »

$ rm *
rm: cannot remove 'Colony S01E05': No such file or directory
rm: cannot remove 'Impulse S02E01': No such file or directory
rm: cannot remove 'Prestonwood 191019 HELP! The God of All Comfort.mp4': No such file or directory

$ ls -al Colony S01E05
ls: cannot access 'Colony': No such file or directory
ls: cannot access 'S01E05': No such file or directory

$ rm "Colony S01E05"
rm: cannot remove 'Colony S01E05': No such file or directory

$ rm Colony\ S01E05
rm: cannot remove 'Colony S01E05': No such file or directory

$ rm Col*
rm: cannot remove 'Colony S01E05': No such file or directory

I tried to rename Colony S01E05 but it won't rename. I get the return popup:
Sorry, could not rename "Colony S01E05" to "Colony-S01E05": Error renaming file /Colony S01E05: Input/output error
metamorphousthe
"It's all about change"
User avatar
Joe2Shoe
Level 5
Level 5
Posts: 550
Joined: Wed Oct 18, 2017 8:12 pm
Location: Ozone

Re: Files Won't Delete From Directory

Post by Joe2Shoe »

To remove ALL files inside that directory:
sudo rm /path-to-folder/foldername/*

Then, to remove that directory (which is now empty):
sudo rm /path-to-folder/foldername

This always works for me, but I'm sure there's a better way.
"Tolerance is the refuge of men without conviction."
"Common sense is not so common" - Voltaire
User avatar
bjornmu
Level 3
Level 3
Posts: 185
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Files Won't Delete From Directory

Post by bjornmu »

Or just do

Code: Select all

rm -rf /path/to/directory
if you're sure it does not contain any files you want to keep.
Buzzsaw
Level 6
Level 6
Posts: 1322
Joined: Sat Aug 23, 2014 12:53 pm

Re: Files Won't Delete From Directory

Post by Buzzsaw »

Input/output error
Hardware is broken.
Post Reply

Return to “Software & Applications”