A live bird collage card for your Home Assistant dashboard.
working on cleanup.sh
Patrick McGuire08074436d6d1
diff --git a/scripts/cleanup.sh b/scripts/cleanup.shindex 27c89988..0b922d64 100755--- a/scripts/cleanup.sh+++ b/scripts/cleanup.sh@@ -2,5 +2,8 @@source /etc/birdnet/birdnet.confcd "${PROCESSED}" || exit 1-FIND_DATE=*$(date --date="2 days ago" "+%F")*-find . -name "${FIND_DATE}" -exec rm -rfv {} ++empties=($(find ${PROCESSED} -size 57c))+for i in "${empties[@]}";do+ rm -f "${i}"+ rm -f "${i/.csv/}"+donediff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.shindex 5fabe839..d3372406 100755--- a/scripts/extract_new_birdsounds.sh+++ b/scripts/extract_new_birdsounds.sh@@ -17,23 +17,6 @@ ANALYZED=${RECS_DIR}/*/*Analyzed# SCAN_DIRS are all directories marked "Analyzed"SCAN_DIRS=($(find ${ANALYZED} -type d | sort ))-# This sets our while loop integer iterator 'a' -- it first checks whether-# there are any extractions, and if so, this instance of the extraction will-# start the 'a' value where the most recent instance left off.-# Ex: If the last extraction file is 189-%date%species.wav, 'a' will be 190.-# Else, 'a' starts at 1-#if [ "$(find ${EXTRACTED} -name '*.wav' | wc -l)" -ge 1 ];then-# a=$(( $( find "${EXTRACTED}" -name '*.wav' \-# | awk -F "/" '{print $NF}' \-# | cut -d'-' -f1 \-# | sort -n \-# | tail -n1 ) + 1 ))-#else-# a=1-#fi--#echo "Starting numbering at ${a}"-for h in "${SCAN_DIRS[@]}";do# The TMPFILE is created from each .csv file BirdNET creates# within each "Analyzed" directory@@ -50,6 +33,7 @@ for h in "${SCAN_DIRS[@]}";dorm -drf "$(echo ${h} | cut -d'-' -f1-3)"continuefi+# Iterates over each "Analyzed" directoryfor i in $(find ${h} -name '*csv' | sort );do# Iterates over each '.csv' file found in each "Analyzed" directory@@ -85,8 +69,7 @@ for h in "${SCAN_DIRS[@]}";doNEWSPECIES_BY_COMMON="${EXTRACTED}/By_Common_Name/${COMMON_NAME// /_}"NEWSPECIES_BY_SCIENCE="${EXTRACTED}/By_Scientific_Name/${SCIENTIFIC_NAME// /_}"- # If the extracted file already exists, increment the 'a' variable once- # but move onto the next line of the TMPFILE for extraction.+ # If the extracted file already exists, move onif [[ -f "${NEWSPECIES_BYDATE}/${NEWFILE}" ]];thenecho "Extraction exists. Moving on"continue@@ -97,7 +80,6 @@ for h in "${SCAN_DIRS[@]}";do# original WAVE file still exists.[[ -f "${h}/${OLDFILE}" ]] || continue-# If a directory does not already exist for the species (by date),# it is created[[ -d "${NEWSPECIES_BYDATE}" ]] || mkdir -p "${NEWSPECIES_BYDATE}"diff --git a/templates/cleanup.cron b/templates/cleanup.cronindex 2c805fa0..c0b629ca 100644--- a/templates/cleanup.cron+++ b/templates/cleanup.cron@@ -1,4 +1,4 @@#birdnet-0 1 * * * /usr/local/bin/cleanup.sh &> /dev/null+0/30 * * * * /usr/local/bin/cleanup.sh &> /dev/null#birdnet@reboot /usr/local/bin/cleanup.sh &> /dev/null