-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
convert.sh
executable file
·60 lines (50 loc) · 1.39 KB
/
convert.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
#!/bin/bash
rm -R romart
rm -R jpg
cd assets
root=$PWD
width=112
bar="⣿"
rm -R romart
rm -R jpg
systems=($(ls -F | grep /))
mkdir romart
mkdir jpg
echo "--------------------------------------------------------------------------"
echo -e "root -> ${root}"
echo "--------------------------------------------------------------------------"
for system in "${systems[@]}"
do
system="${system%?}";
cd $system;
total=($(ls -l | grep -v ^l | wc -l))
echo "$system - has $total files";
mkdir "${root}/jpg/${system}"
mkdir "${root}/romart/${system}"
complete=0
percent=0
calc=0
find . -type f -name "*.png" -print0 | while IFS= read -r -d '' file;
do
bars=""
complete=$((complete+1))
calc=$(( (100 * complete / total + (1000 * complete / total % 10 >= 5 ? 1 : 0)) / 2 ))
if [ "$calc" -gt "$percent" ];then
clear
percent=$calc
for (( i=0; i<$percent; ++i)); do
bars="${bars}${bar}"
done
echo "--------------------------------------------------------------------------"
echo -e "Converting -> ${system} files: ${complete}/${total}"
echo "$((percent * 2 ))% ${bars}"
echo "--------------------------------------------------------------------------"
fi
convert "${file}" -resize ${width} -quality 75 "${root}/jpg/${system}/${file%.*}.jpg"
done
cd $root
done
cp -r jpg ../jpg
cp -r romart ../romart
rm -R jpg
rm -R romart