Page 1 of 1

Can't delete files with corrupt filenames

Posted: Sun Feb 17, 2013 8:41 pm
by KevinP
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?
cant-delete.png

Re: Can't delete files with corrupt filenames

Posted: Sun Feb 17, 2013 10:26 pm
by wayne128
try to rename the file..then delete

Re: Can't delete files with corrupt filenames

Posted: Mon Feb 18, 2013 3:37 am
by pgmer6809
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
rm -R BADDIR
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:
badname1_goodsfx_3206
badname2_goodsfx_1209
badname3_goodsfx_30555
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.
pgmer6809

Re: Can't delete files with corrupt filenames

Posted: Fri May 24, 2013 1:29 pm
by LindseyD.
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.

Re: Can't delete files with corrupt filenames

Posted: Fri May 24, 2013 1:43 pm
by TBABill
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.

Re: Can't delete files with corrupt filenames

Posted: Fri May 24, 2013 3:34 pm
by DrHu
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
http://techthrob.com/2009/03/02/howto-d ... -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..)