Can't delete files with corrupt filenames

Forum rules
Before you post please read how to get help
Level 1
Level 1
Posts: 23
Joined: Tue Feb 08, 2011 7:17 pm

Can't delete files with corrupt filenames

Postby KevinP » Sun Feb 17, 2013 8:41 pm

As seen in this graphic, I have some files that won't delete because their filenames are corrupt. These files were created on a Korean edition of Windows. I do have Korean language support installed (which, of course, doesn't look like this) so that's not why I can't access them.

Don't need to open them, just delete them. Any help?


Level 10
Level 10
Posts: 3412
Joined: Tue Jul 13, 2010 12:15 am

Re: Can't delete files with corrupt filenames

Postby wayne128 » Sun Feb 17, 2013 10:26 pm

try to rename the file..then delete

Level 3
Level 3
Posts: 124
Joined: Sun Mar 04, 2012 9:06 pm

Re: Can't delete files with corrupt filenames

Postby pgmer6809 » Mon Feb 18, 2013 3:37 am

If all those files are in a directory you could cd to the parent of that directory and then rm the whole directory.
eg. the garbage files are in /mnt/work/BADDIR
and BADDIR contains ONLY those files you want to delete.
you could

Code: Select all

cd /mnt/work

If there are files in BADDIR you want to keep you could do something like this:

Code: Select all

find BADDIR -name '*' -exec mv \{\} \{\}_goodsfx_$RANDOM \;

this will rename the files keeping their current messed up name, but appending the string _goodsfx_nnnnn
to them, where nnnn is a random integer.
Now each file has a unique name you can refer to.
say your directory now looks like this:
where the 'badname' part of the above example is the filename you cant type in.
and you want to keep badname3 but delete the others. Of course you cant type the character string badname3 because it is messed up.
you could say though
mv BADDIR/*goodsfx_30555 GOODDIR/goodname3
to move badname3 out of BADDIR to GOODDIR and give it a new name that you like.
in spite of the wild card only one file will move because the digits at the end are unique. or should be.
now with the good files moved out of BADDIR you can say rm -R BADDIR as before.

Level 4
Level 4
Posts: 329
Joined: Fri Mar 26, 2010 12:35 pm

Re: Can't delete files with corrupt filenames

Postby LindseyD. » Fri May 24, 2013 1:29 pm

There's a suite of utilities called renameutils. Once you've installed it, the one you want is qmv.

In a terminal, switch to the directory where the files are, and enter qmv. You'll see the Nano text editor with two columns (best to use the terminal in full screen mode). The one on the left is the current filename, you'll have change the filenames in the right-hand column. It's a PITA, but the only way I've ever found of renaming/deleting these files. I also believe it's possible to do this in Kate. but the one time I tried it I botched the job. Nano's clumsy but it works. Save the file (it'll have a /tmp/lots_of_letters_and_numbers name) and you should be okay. If you've got a lot of files, you might want to take a mild tranquillizer first.
Mint17 KDE

Level 6
Level 6
Posts: 1362
Joined: Wed Dec 30, 2009 1:02 pm
Location: Leonardtown, MD

Re: Can't delete files with corrupt filenames

Postby TBABill » Fri May 24, 2013 1:43 pm

I haven't tried in a very long time, but if the file names are in letters, numbers and standard keyboard symbols, can you enter a terminal, display contents of that directory they are in, then delete by typing in the file name as it exists in terminal? Could even copy/paste the file name following the delete command. Not sure if that'll work for corrupted files, but worth a shot.

User avatar
Level 17
Level 17
Posts: 7543
Joined: Wed Jun 17, 2009 8:20 pm

Re: Can't delete files with corrupt filenames

Postby DrHu » Fri May 24, 2013 3:34 pm

If it is really Korean, you could add that language so that you could easily see the filename, or you could try the rename routine or you could try shredding the filename ... -in-linux/
--if you can't you could try killing it by extensions (I see *.xls there)
    First I would move that set *.xls to another storage location (folder..)

Return to “KDE”