Skip to content

Instantly share code, notes, and snippets.

@Efrat19
Last active December 10, 2019 15:26
Show Gist options
  • Save Efrat19/bd0f4fb9cb793abd253ba442313e3eb5 to your computer and use it in GitHub Desktop.
Save Efrat19/bd0f4fb9cb793abd253ba442313e3eb5 to your computer and use it in GitHub Desktop.
convert dir to utf8
#!/bin/bash
#enter input encoding here
FROM_ENCODING="WINDOWS-1255"
#output encoding(UTF-8)
TO_ENCODING="UTF-8"
#convert
CONVERT=" iconv -f $FROM_ENCODING -t $TO_ENCODING"
#loop to convert multiple files
for file in $(find $1 -type f -name "*.php"); do
$CONVERT "$file" > "${file}.encoded" && mv "${file}.encoded" $file
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment