Skip to content

Managing Song Storage for Rare vs Common species #796

Answered by ehpersonal38
winedarksea asked this question in Q&A
Discussion options

You must be logged in to vote

This script should work, or at least give you some ideas. You'll have to un-comment the rm if you actually want to delete the directories, otherwise it'll just print out "REMOVING". It will only keep the bottom 10% of species by count, change 0.1 in the script as desired.

#!/bin/bash

# Set variables
db_path=~/BirdNET-Pi/scripts/birds.db
dir_path=~/BirdSongs/Extracted/By_Date

# Calculate the average count of detections for each species
avg_counts=$(sqlite3 $db_path "SELECT Com_Name || '|' || AVG(count) FROM (SELECT Com_Name, COUNT(*) as count FROM detections GROUP BY Com_Name) GROUP BY Com_Name ORDER BY AVG(count)")

# Get the species that are in the bottom 10% of this distribution by count

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@winedarksea
Comment options

Answer selected by winedarksea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants