Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert all files of a dir to UTF8

Convert files of a dir to UTF8

Run this script on linux.
Modify the "find" call and the source encoding.
The example will match all .java files in the current folder and its subfolders and converts from Cp1252 (Windows) to UTF-8.

#!/bin/bash

# modify this find call for your needs
list=$(find . -type f -name "*.java")

for item in $list
do
        echo "Item: $item"

        # change source and target encoding here
        iconv -f Cp1252 -t UTF-8 $item > ${item}.x
        cp ${item}.x ${item}
        rm ${item}.x
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.