On various filesystems, I have a bunch of filesystem entries that have badly-encoded names (they were written with the wrong character encoding).

How can I automatically list all entries with names that are invalid for the current character encoding?

Having found all those entries, how can I automatically rename them all from one encoding to another?

link|improve this question

75% accept rate
2  
It would help if you could let us know which filesystem in particular. – squillman Jun 9 '09 at 5:00
Or operating system at least. – David Pashley Jun 9 '09 at 8:04
feedback

1 Answer

up vote 1 down vote accepted

I'd simply do a

convmv -r -f ASCII -t UTF-8 $targetdir

unless you add the --notest it won't actually do anything to your files. Defaults assume the from encoding is ASCII and to encoding is UTF-8. Pipe that thru awk '{print $2}' to only get the filenames that would be converted.

Note: I'm assuming you are using Linux. Most POSIX filesystems don't care about the encoding of filenames, however the manpage of convmv has a couple of details (also how to decode double UTF-8 encoded filenames)

link|improve this answer
What does -f ASCII -t UTF-8 do? It looks like it would convert ASCII to UTF-8, which is a no-op, as ASCII is a subset of UFT-8. – sleske Jun 10 '09 at 1:52
1  
That is correct but I rather give noop commands than kill someone elses box and take the blame for it. Thou convmv doesn't actually do anything without the --notest. But Murphey never sleeps :) – Server Horror Jun 10 '09 at 2:12
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.