Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

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)

share|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
2  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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