Can't delete files with corrupt filenames

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
KevinP

Can't delete files with corrupt filenames

Post 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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
wayne128

Re: Can't delete files with corrupt filenames

Post by wayne128 »

try to rename the file..then delete
pgmer6809
Level 4
Level 4
Posts: 228
Joined: Sun Mar 04, 2012 9:06 pm

Re: Can't delete files with corrupt filenames

Post 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
LindseyD.
Level 4
Level 4
Posts: 333
Joined: Fri Mar 26, 2010 12:35 pm

Re: Can't delete files with corrupt filenames

Post 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.
Mint17 KDE
TBABill
Level 6
Level 6
Posts: 1355
Joined: Wed Dec 30, 2009 1:02 pm
Location: Leonardtown, MD

Re: Can't delete files with corrupt filenames

Post 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.
DrHu

Re: Can't delete files with corrupt filenames

Post 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..)
Locked

Return to “Software & Applications”