diff --git a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh index 61fca2bc6..e515ae302 100755 --- a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh +++ b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh @@ -4,12 +4,15 @@ # Check if there are files in "$HOME"/BirdSongs/StreamData and move them to /data/StreamData if [ -d /data/StreamData ] && [ "$(ls -A /data/StreamData/)" ]; then - bashio::log.warning "Container was stopped while files were still being analysed, restoring them" + # Count the number of .wav files in /data/StreamData + wav_count=$(find /data/StreamData -type f -name "*.wav" | wc -l) + bashio::log.warning "Container was stopped while files were still being analyzed, restoring $wav_count .wav files" # Copy files - if [ "$(ls -A /data/StreamData)" ]; then + if [ "$wav_count" -gt 0 ]; then mv -v /data/StreamData/* "$HOME"/BirdSongs/StreamData/ fi + echo "... done" echo "" @@ -21,4 +24,3 @@ if [ -d /data/StreamData ] && [ "$(ls -A /data/StreamData/)" ]; then rm -r /data/StreamData fi -