Millet Porridge

English version of https://corvo.myseu.cn

0%

Batch Encoding Conversion on Linux

Many subtitle files downloaded from the internet are not in utf-8, which is a bit painful to use on Linux. Fortunately iconv can convert them easily, but converting one file at a time is never convenient — hence this little script I wrote.

Batch-convert all the files in a folder and save them into a newly created convert directory

1
2
3
4
5
6
7
8
9
#!/bin/bash

mkdir -pv convert # make sure the folder exists

for i in `find -maxdepth 1 -name "*.ass"`; # find ass files in the directory
do
iconv -c -f GB2312 -t UTF-8 $i -o convert/$i # convert and save
echo $i "convert success"
done

Feel free to modify it to fit your own situation.