Skip to content

Instantly share code, notes, and snippets.

@lucas-tulio
Created September 19, 2014 16:43
Show Gist options
  • Save lucas-tulio/9a27545057c60ee84f98 to your computer and use it in GitHub Desktop.
Save lucas-tulio/9a27545057c60ee84f98 to your computer and use it in GitHub Desktop.
Converts the encoding of .java files from Mac Roman to UTF-8
echo "#############################################################################################"
echo "This script will recursively convert the encoding of all *.java files from Mac Roman to UTF8!"
echo "All java files in this dir and subdirs will be changed."
echo "Only files with special characters will be changed. Probably."
echo
echo "Data may be lost. Use it at your own risk!"
echo "#############################################################################################"
read -p "Sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[YySs]$ ]]
then
echo "D-D-D-D-DROP THE BASS"
for file in $(find . -name "*.java"); do
mv "$file" "$file MR"
iconv -f MACROMAN -t UTF8 "$file MR" > "$file";
rm "$file MR"
done
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment