mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-02 22:04:06 +02:00
Update changeidenfication.sh
This commit is contained in:
@@ -8,16 +8,26 @@ set +u #avoid error with apprise variables
|
|||||||
# SET VARIABLES #
|
# SET VARIABLES #
|
||||||
#################
|
#################
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
# Get arguments
|
||||||
source /etc/birdnet/birdnet.conf
|
OLDNAME="$1" #OLDNAME="Mésange_charbonnière-78-2024-05-02-birdnet-RTSP_1-18:14:08.mp3"
|
||||||
OLDNAME="" #OLDNAME="Mésange_charbonnière-78-2024-05-02-birdnet-RTSP_1-18:14:08.mp3"
|
NEWNAME="$2" #NEWNAME="Lapinus atricapilla_Lapinu à tête noire"
|
||||||
NEWNAME="" #NEWNAME="Lapinus atricapilla_Lapinu à tête noire"
|
|
||||||
OLDNAME="$1"
|
# Fixed values
|
||||||
NEWNAME="$2"
|
|
||||||
LABELS_FILE="$HOME/BirdNET-Pi/model/labels.txt"
|
LABELS_FILE="$HOME/BirdNET-Pi/model/labels.txt"
|
||||||
DB_FILE="$HOME/BirdNET-Pi/scripts/birds.db"
|
DB_FILE="$HOME/BirdNET-Pi/scripts/birds.db"
|
||||||
DETECTIONS_TABLE="detections"
|
DETECTIONS_TABLE="detections"
|
||||||
|
|
||||||
|
# Extract the part before the _ from $NEWNAME
|
||||||
|
NEWNAME_comname="${NEWNAME#*_}"
|
||||||
|
NEWNAME_sciname="${NEWNAME%%_*}"
|
||||||
|
|
||||||
|
# Replace spaces with underscores
|
||||||
|
NEWNAME_comname2="${NEWNAME_comname// /_}"
|
||||||
|
OLDNAME_comname2="${OLDNAME_comname// /_}"
|
||||||
|
|
||||||
|
# Replace OLDNAME_comname2 with NEWNAME_comname2 in OLDNAME
|
||||||
|
NEWNAME_filename="${OLDNAME//$OLDNAME_comname2/$NEWNAME_comname2}"
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# VALIDITY CHECKS #
|
# VALIDITY CHECKS #
|
||||||
###################
|
###################
|
||||||
@@ -51,23 +61,12 @@ if [[ -z "$OLDNAME_sciname" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "This script will change the identification $OLDNAME from $OLDNAME_comname to $NEWNAME_comname"
|
echo "This script will change the identification $OLDNAME from $OLDNAME_comname to ${NEWNAME#*_}"
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# EXECUTE : MOVE FILES #
|
# EXECUTE : MOVE FILES #
|
||||||
########################
|
########################
|
||||||
|
|
||||||
# Extract the part before the _ from $NEWNAME
|
|
||||||
NEWNAME_comname="${NEWNAME#*_}"
|
|
||||||
NEWNAME_sciname="${NEWNAME%%_*}"
|
|
||||||
|
|
||||||
# Replace spaces with underscores
|
|
||||||
NEWNAME_comname2="${NEWNAME_comname// /_}"
|
|
||||||
OLDNAME_comname2="${OLDNAME_comname// /_}"
|
|
||||||
|
|
||||||
# Replace OLDNAME_comname2 with NEWNAME_comname2 in OLDNAME
|
|
||||||
NEWNAME_filename="${OLDNAME//$OLDNAME_comname2/$NEWNAME_comname2}"
|
|
||||||
|
|
||||||
# Check if the file exists
|
# Check if the file exists
|
||||||
FILE_PATH="$HOME/BirdSongs/Extracted/By_Date/$OLDNAME_date/$OLDNAME_comname2/$OLDNAME"
|
FILE_PATH="$HOME/BirdSongs/Extracted/By_Date/$OLDNAME_date/$OLDNAME_comname2/$OLDNAME"
|
||||||
if [[ -f $FILE_PATH ]]; then
|
if [[ -f $FILE_PATH ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user