-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuckheic
87 lines (83 loc) · 2.17 KB
/
fuckheic
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
#!/bin/bash
heifcnt=0
heiccnt=0
currentfolder=$(pwd)
case "$1" in
--png)
echo ":: Converting everything to PNG format"
filetype="png"
;;
*)
echo ":: Converting everything to JPG format"
filetype="jpg"
;;
esac
for file in $currentfolder/*; do
if [[ $file == *.HEIC ]]; then
if [[ $filetype = "jpg" ]]; then
if [ -f "${file%.*}.jpg" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heiccnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
elif [[ $filetype = "png" ]]; then
if [ -f "${file%.*}.png" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heiccnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
fi
elif [[ $file == *.heic ]]; then
if [[ $filetype = "jpg" ]]; then
if [ -f "${file%.*}.jpg" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heiccnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
elif [[ $filetype = "png" ]]; then
if [ -f "${file%.*}.png" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heiccnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
fi
elif [[ $file == *.HEIF ]]; then
if [[ $filetype = "jpg" ]]; then
if [ -f "${file%.*}.jpg" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heifcnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
elif [[ $filetype = "png" ]]; then
if [ -f "${file%.*}.png" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heifcnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
fi
elif [[ $file == *.heif ]]; then
if [[ $filetype = "jpg" ]]; then
if [ -f "${file%.*}.jpg" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heifcnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
elif [[ $filetype = "png" ]]; then
if [ -f "${file%.*}.png" ]; then
echo ":: Skipping. File ${file} already converted"
else
((heifcnt++))
heif-convert "$file" "${file%.*}.$filetype"
fi
fi
fi
done
printf '\n:: .heic converted: %d file(s)\n' "$heiccnt"
printf ':: .heif converted: %d file(s)\n' "$heifcnt"