-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.sh
executable file
·31 lines (27 loc) · 975 Bytes
/
report.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
#!/bin/bash
# Check if a directory was provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 DIRECTORY"
exit 1
fi
# Find all .pie files in the directory
FILES=$(ls "$1"/*.pie 2>/dev/null)
# Loop through each .pie file and compare its size to other .pie files with the same stem
for FILE in $FILES; do
# Get the file stem by removing the extension
STEM=$(basename "$FILE" | cut -d'.' -f1)
# Check if there are other .png files with the same stem
OTHER_FILES=$(ls "$1/$STEM"*.png 2>/dev/null)
if [ -n "$OTHER_FILES" ]; then
# Loop through each other .png file and compare its size to the current .pie file
for OTHER_FILE in $OTHER_FILES; do
if [ "$FILE" != "$OTHER_FILE" ]; then
SIZE1=$(wc -c <"$FILE")
SIZE2=$(wc -c <"$OTHER_FILE")
DIFF=$(expr $SIZE2 - $SIZE1)
PERCENT=$(echo "scale=2; 100 - ($DIFF / $SIZE2 * 100)" | bc)
echo "$FILE is $PERCENT% the size of the .png"
fi
done
fi
done