Files
ISISeg/Tools_scripts_XunFei-Ubuntu/check_audio_duration.sh

22 lines
567 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
TARGET="${1:-02_audio}"
if ! command -v ffprobe >/dev/null 2>&1; then
echo "ffprobe is required. Install it with: sudo apt install -y ffmpeg" >&2
exit 1
fi
if [[ ! -e "$TARGET" ]]; then
echo "Path not found: $TARGET" >&2
exit 1
fi
find "$TARGET" -type f \( -iname '*.mp3' -o -iname '*.wav' -o -iname '*.m4a' \) -print0 |
sort -z |
while IFS= read -r -d '' file; do
duration="$(ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 "$file")"
printf '%8.3fs %s\n' "$duration" "$file"
done