[Bash] Convert Files in Directory From Big5 to UTF-8
Question:
A lot of HTML files under dhpstory directory. The encoding of the files is Big5. Converted them to UTF-8 encoding via iconv command.
Answer:
1 2 3 4 5 6 7 8 9 10 | #!/bin/sh
# Convert all files in directory from Big5 to UTF-8
# list all files recursively
for file in $(find dhpstory/ -type f)
do
output=${file}-utf8.html
echo "\033[92mConverting ${file} (BIG5) to ${output} (UTF8) ...\033[0m"
iconv -f BIG5 -t UTF8 ${file} > ${output}
done
|
References:
[1] | [Bash] List All Files in Directory Recursively and Rename |