Can't delete files with corrupt filenames

Forum rules
Before you post please read this

Can't delete files with corrupt filenames

Postby KevinP on 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?

cant-delete.png
cant-delete.png (48.1 KiB) Viewed 945 times
KevinP
Level 1
Level 1
 
Posts: 23
Joined: Tue Feb 08, 2011 7:17 pm

Linux Mint is funded by ads and donations.
 

Re: Can't delete files with corrupt filenames

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

try to rename the file..then delete
wayne128
Level 10
Level 10
 
Posts: 3319
Joined: Tue Jul 13, 2010 12:15 am

Re: Can't delete files with corrupt filenames

Postby pgmer6809 on 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
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
pgmer6809
Level 2
Level 2
 
Posts: 96
Joined: Sun Mar 04, 2012 9:06 pm

Re: Can't delete files with corrupt filenames

Postby LindseyD. on 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.
Mint15 KDE
LindseyD.
Level 4
Level 4
 
Posts: 260
Joined: Fri Mar 26, 2010 12:35 pm

Re: Can't delete files with corrupt filenames

Postby TBABill on 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.
TBABill
Level 6
Level 6
 
Posts: 1368
Joined: Wed Dec 30, 2009 1:02 pm
Location: Leonardtown, MD

Re: Can't delete files with corrupt filenames

Postby DrHu on 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
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..)
User avatar
DrHu
Level 16
Level 16
 
Posts: 6710
Joined: Wed Jun 17, 2009 8:20 pm


Return to KDE

Who is online

Users browsing this forum: No registered users and 4 guests