Skip to content

Instantly share code, notes, and snippets.

@cssence
Last active March 9, 2016 11:22
Show Gist options
  • Save cssence/11d060fb780ad740800d to your computer and use it in GitHub Desktop.
Save cssence/11d060fb780ad740800d to your computer and use it in GitHub Desktop.
Convert text files to UTF-8
#!/usr/bin/env bash
if [[ $1 == -f ]]; then
format="$2"
shift 2
fi
for file in $@; do
iconv -f ${format-"windows-1252"} -t "UTF-8" "$file" > "${file%.*}.utf8.$(echo $file |awk -F . '{if (NF>1) {print $NF}}')"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment