forked from aamador-ch-en/HigReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alt_start_conversion.sh
executable file
·152 lines (138 loc) · 4.5 KB
/
alt_start_conversion.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh
output_name_initial="Higurashi_<insert_arc_name>_initial.txt"
output_name_final="Higurashi_<insert_arc_name>.txt"
script_dir="script"
exe_name="higureader.out"
source_name="higureader.c"
if [ -f "$output_name_final" ]
then
echo "Removing previous $output_name_final ..."
rm -f "$output_name_final"
echo "Done"
fi
#Renames files so that the order of the files are perfect
echo "Renaming files- "
if [ -f "$script_dir"/onik_009.txt ];
then
echo "onik_009.txt to onik_009_00.txt"
cp "$script_dir"/onik_009.txt "$script_dir"/onik_009_00.txt
mv "$script_dir"/onik_009.txt "$script_dir"/onik_009.txt.backup
fi
if [ -f "$script_dir"/onik_014.txt ];
then
echo "onik_014.txt to onik_014_00.txt"
cp "$script_dir"/onik_014.txt "$script_dir"/onik_014_00.txt
mv "$script_dir"/onik_014.txt "$script_dir"/onik_014.txt.backup
fi
if [ -f "$script_dir"/onik_015.txt ];
then
echo "onik_015.txt to onik_015_00.txt"
cp "$script_dir"/onik_015.txt "$script_dir"/onik_015_00.txt
mv "$script_dir"/onik_015.txt "$script_dir"/onik_015.txt.backup
fi
if [ -f "$script_dir"/wata_009.txt ];
then
echo "wata_009.txt to wata_009_00.txt"
cp "$script_dir"/wata_009.txt "$script_dir"/wata_009_00.txt
mv "$script_dir"/wata_009.txt "$script_dir"/wata_009.txt.backup
fi
if [ -f "$script_dir"/wata_010.txt ];
then
echo "wata_010.txt to wata_010_00.txt"
cp "$script_dir"/wata_010.txt "$script_dir"/wata_010_00.txt
mv "$script_dir"/wata_010.txt "$script_dir"/wata_010.txt.backup
fi
if [ -f "$script_dir"/wata_011.txt ];
then
echo "wata_011.txt to wata_011_00.txt"
cp "$script_dir"/wata_011.txt "$script_dir"/wata_011_00.txt
mv "$script_dir"/wata_011.txt "$script_dir"/wata_011.txt.backup
fi
if [ -f "$script_dir"/wata_012.txt ];
then
echo "wata_012.txt to wata_012_00.txt"
cp "$script_dir"/wata_012.txt "$script_dir"/wata_012_00.txt
mv "$script_dir"/wata_012.txt "$script_dir"/wata_012.txt.backup
fi
if [ -f "$script_dir"/tata_008.txt ];
then
echo "tata_008.txt to tata_008_00.txt"
cp "$script_dir"/tata_008.txt "$script_dir"/tata_008_00.txt
mv "$script_dir"/tata_008.txt "$script_dir"/tata_008.txt.backup
fi
if [ -f "$script_dir"/tata_009.txt ];
then
echo "tata_009.txt to tata_009_00.txt"
cp "$script_dir"/tata_009.txt "$script_dir"/tata_009_00.txt
mv "$script_dir"/tata_009.txt "$script_dir"/tata_009.txt.backup
fi
if [ -f "$script_dir"/tata_010.txt ];
then
echo "tata_010.txt to tata_010_00.txt"
cp "$script_dir"/tata_010.txt "$script_dir"/tata_010_00.txt
mv "$script_dir"/tata_010.txt "$script_dir"/tata_010.txt.backup
fi
if [ -f "$script_dir"/tata_011.txt ];
then
echo "tata_011.txt to tata_011_00.txt"
cp "$script_dir"/tata_011.txt "$script_dir"/tata_011_00.txt
mv "$script_dir"/tata_011.txt "$script_dir"/tata_011.txt.backup
fi
if [ -f "$script_dir"/tata_013.txt ];
then
echo "tata_013.txt to tata_013_00.txt"
cp "$script_dir"/tata_013.txt "$script_dir"/tata_013_00.txt
mv "$script_dir"/tata_013.txt "$script_dir"/tata_013.txt.backup
fi
if [ -f "$script_dir"/hima_002.txt ];
then
echo "hima_002.txt to hima_002_00.txt"
cp "$script_dir"/hima_002.txt "$script_dir"/hima_002_00.txt
mv "$script_dir"/hima_002.txt "$script_dir"/hima_002.txt.backup
fi
if [ -f "$script_dir"/hima_003.txt ];
then
echo "hima_003.txt to hima_003_00.txt"
cp "$script_dir"/hima_003.txt "$script_dir"/hima_003_00.txt
mv "$script_dir"/hima_003.txt "$script_dir"/hima_003.txt.backup
fi
if [ -f "$script_dir"/hima_003_03.txt ];
then
echo "hima_003_03.txt to hima_003_030.txt"
cp "$script_dir"/hima_003_03.txt "$script_dir"/hima_003_030.txt
mv "$script_dir"/hima_003_03.txt "$script_dir"/hima_003_03.txt.backup
fi
echo "Creating new higheader executable..."
gcc higureader.c -o "$exe_name"
echo "Done"
echo "Creating $output_name_initial ..."
echo "Processing files-"
#executes the program with the opening script first
if [ -f "$script_dir"/*_op.txt ];
then
./"$exe_name" "$script_dir"/*_op.txt >> "$output_name_initial"
echo "$script_dir"/*op.txt
fi
for file in "$script_dir"/*.txt
do
if [ "$file" != "$script_dir"/*_op.txt ];
then
echo "$file"
./"$exe_name" "$file" >> "$output_name_initial"
fi
done
if [ -f "$output_name_initial" ]
then
echo "$output_name_initial successfully created."
else
echo "Error! $output_name_initial not created!"
fi
echo "Removing unwanted characters from $output_name_initial and creating $output_name_final..."
sed $'s/[^[:print:]\t]//g' "$output_name_initial" > "$output_name_final"
if [ -f "$output_name_final" ]
then
echo "$output_name_final successfully created."
rm -f "$output_name_initial"
else
echo "Error! $output_name_final not created!"
fi