Add catalog.sh

This commit is contained in:
HHF Technology 2024-12-08 20:38:35 +05:30
commit 4e3234a849

23
catalog.sh Normal file
View file

@ -0,0 +1,23 @@
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
NC='\033[0m'
$CAT_DIR
echo -e "--------- ${GREEN}CATALOGING ISO FILES${NC} ------------"
find $CAT_DIR -type f | for FILENAME in $(find $CAT_DIR -type f ); do ls -lh $FILENAME | sed 's/ /_/g'; done | grep -E -v ".txt|.sh|SUM|sha|asc|MD5|torrent|.xml|sig|sha256|padding_file|sqlite" | wc -l | awk '{ print $1 }' > cat.temp
CAT_SIZE_NUM=$(cat cat.temp | head -n 1)
rm cat.temp
echo -e "Number of files in archive: ${YELLOW} $CAT_SIZE_NUM ${NC}"
CAT_SIZE_SPACE_PRETTY=$(du -sh $CAT_DIR | grep -v .txt | grep -v .sh | grep -v SUM | grep -v sha | grep -v asc | grep -v MD5 | grep -v torrent | awk '{ print $1 }')
CAT_SIZE_SPACE=$(echo $CAT_SIZE_SPACE_PRETTY | sed 's/[^0-9]//g')
echo -e "Size of archive: ${YELLOW} $CAT_SIZE_SPACE_PRETTY ${NC}"
CAT_SIZE_SPACE_PRETTY=$(du -sh $CAT_DIR | awk '{ print $1 }' | sed 's/G//')
CAT_SIZE_AVG=$(python3 -c "print($CAT_SIZE_SPACE/$CAT_SIZE_NUM)" | cut -c1-4)G
echo -e "Average size of file: ${YELLOW} $CAT_SIZE_AVG ${NC}"
find $CAT_DIR -type f | for FILENAME in $(find $CAT_DIR -type f ); do ls -lh $FILENAME | awk '{ print $5 " " $9 }' ; done | sort -n > content.txt
echo -e "Updated catalog in ${YELLOW}content.txt...${NC}"
echo -e "${RED}Finished!${NC}"