-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_sizes.sh
40 lines (38 loc) · 1.69 KB
/
file_sizes.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
#!/bin/bash
find ./public/ -name "*.jpg" -type f -size +300k -exec ls -lh {} \; | awk '{ print "jpg/Image " $9 " is too big: " $5 }'
find ./public/ -name "*.JPG" -type f -size +300k -exec ls -lh {} \; | awk '{ print "JPG/Image " $9 " is too big: " $5 }'
find ./public/ -name "*.jpeg" -type f -size +300k -exec ls -lh {} \; | awk '{ print "jpeg/Image " $9 " is too big: " $5 }'
find ./public/ -name "*.JPEG" -type f -size +300k -exec ls -lh {} \; | awk '{ print "JPEG/Image " $9 " is too big: " $5 }'
find ./public/ -name "*.png" -type f -size +300k -exec ls -lh {} \; | awk '{ print "png/Image " $9 " is too big: " $5 }'
find ./public/ -name "*.PNG" -type f -size +300k -exec ls -lh {} \; | awk '{ print "PNG/Image " $9 " is too big: " $5 }'
find ./public/ -name "*.gif" -type f -size +300k -exec ls -lh {} \; | awk '{ print "gif/Image " $9 " is too big: " $5 }'
find ./public/ -name "*.GIF" -type f -size +300k -exec ls -lh {} \; | awk '{ print "GIF/Image " $9 " is too big: " $5 }'
# Find a way to do this in one line.....
if [ -n "$(find ./public/ -name "*.jpg" -type f -size +300k)" ]
then
exit 1
elif [ -n "$(find ./public/ -name "*.JPG" -type f -size +300k)" ]
then
exit 1
elif [ -n "$(find ./public/ -name "*.jpeg" -type f -size +300k)" ]
then
exit 1
elif [ -n "$(find ./public/ -name "*.JPEG" -type f -size +300k)" ]
then
exit 1
elif [ -n "$(find ./public/ -name "*.png" -type f -size +300k)" ]
then
exit 1
elif [ -n "$(find ./public/ -name "*.PNG" -type f -size +300k)" ]
then
exit 1
elif [ -n "$(find ./public/ -name "*.gif" -type f -size +300k)" ]
then
exit 1
elif [ -n "$(find ./public/ -name "*.GIF" -type f -size +300k)" ]
then
exit 1
else
echo "No problems. All images are less than 300kb"
fi
exit 0