Last active
January 25, 2017 23:15
-
-
Save s4l1h/7f7d86b65467441487290ec76dccf838 to your computer and use it in GitHub Desktop.
Multiple File Encoding Conversion Raw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Test On Mac OS X | |
| # | |
| #enter input encoding here | |
| FROM_ENCODING="ISO-8859-9" | |
| #output encoding(UTF-8) | |
| TO_ENCODING="UTF-8//TRANSLIT" | |
| #convert | |
| #iconv -f ISO-8859-9 -t UTF-8//TRANSLIT index.php -o index.php.utf8 | |
| CONVERT="iconv -f $FROM_ENCODING -t $TO_ENCODING" | |
| #loop to convert multiple files | |
| for file in *.php; do | |
| $CONVERT "$file" > "$file.utf8" #mac | |
| # $CONVERT "$file" -o "$file.utf8" #linux | |
| done | |
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #mv index.php.utf8 index.php | |
| for filename in *.utf8; do | |
| [ -f "$filename" ] || continue | |
| mv $filename ${filename//\.utf8/} | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment