Leser: 26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
DIRECTORY_PATH='/home/paddy/tmp/ivmf/'
RECODE='/usr/bin/recode'
for i in ${DIRECTORY_PATH}*.csv
do
ENCODING=$(file $i | awk '{print $2}')
if [[ $ENCODING == 'UTF-8' || $ENCODING == 'ASCII' ]]
then
echo 'Nothing to be done for '$i' '$ENCODING
else
if [[ $ENCODING -eq 'ISO-8859' ]]
then
echo 'Recoding '$i' from '$ENCODING'-1 to UTF-8'
${RECODE} ${ENCODING}'-1..u8' $i
elif [[ $ENCODING -eq 'Non-ISO' ]]
then
echo 'Recoding '$i' from '$ENCODING' to UTF-8'
${RECODE} 'CP1252/CR-LF..u8' $i
else
echo $ENCODING
fi
fi
done