-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencoding-converter.sh
More file actions
executable file
·42 lines (28 loc) · 888 Bytes
/
encoding-converter.sh
File metadata and controls
executable file
·42 lines (28 loc) · 888 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
set -e
# Creating Backup Folder
BACKUP=.BACKUP-`date +%y-%m-%m`
if [ ! -d ${BACKUP} ]; then
echo "creating... ${BACKUP}";
mkdir ${BACKUP};
fi
######################
# Setting Parameters #
######################
FROM_ENC=TIS-620 # Convert from ${FROM_ENC} encoding
TO_ENC=UTF-8 # Convert to ${TO_ENC} encoding
INPUT_FILE=./.aspx.list # list of files will be converted. ! it should be full path
n=0 # count number of converted files
while read p; do
file=$(awk -F '\:' '{print $1}'<<<$p);
filename=$(awk -F '/' '{print $NF}' <<< $file);
printf "prepare converting %s\n" $filename;
echo "backup..."
cp ${file} ${BACKUP}/${filename}.orig;
echo "convert..."
iconv -f ${FROM_ENC} -t ${TO_ENC} ${file} > ${file}.convert
echo "saving..."
mv ${file}.convert ${file}
((n++));
done < ${INPUT_FILE}
printf "number of records: %d\n" ${n}