1

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?

2
  • 2
    It would help if you could let us know which filesystem in particular.
    – squillman
    Jun 9, 2009 at 5:00
  • Or operating system at least. Jun 9, 2009 at 8:04

1 Answer 1

1

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)

2
  • 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, 2009 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 :) Jun 10, 2009 at 2:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .