-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_missing_metadata.sh
53 lines (44 loc) · 1.37 KB
/
check_missing_metadata.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Name: PhinellyPort
# Author: Mattias Ghodsian
# License: MIT License
# Url: https://github.com/mattiasghodsian/PhinellyPort
source header.sh
if ! command -v ffprobe &> /dev/null; then
echo "Error: ffprobe is not installed. Please install FFmpeg."
exit 1
fi
get_metadata() {
file="$1"
tag_name=${2:-"genre"}
ffprobe_output=$(ffprobe -v quiet -show_entries format_tags="$tag_name" -of default=noprint_wrappers=1:nokey=1 "$file")
echo "$ffprobe_output"
}
process_folder() {
folder="$1"
tag_name="$2"
audio_extensions=("mp3" "flac" "wav" "ogg") # Add more audio extensions as needed
shopt -s nullglob
for file in "$folder"/*; do
if [ -d "$file" ]; then
process_folder "$file" "$tag_name"
elif [ -f "$file" ]; then
# Check if the file is an audio file with a valid extension
if echo "${audio_extensions[@]}" | grep -q -w "${file##*.}"; then
tag_value=$(get_metadata "$file" "$tag_name")
if [ -z "$tag_value" ]; then
echo "$tag_name tag is missing in file: $file"
fi
fi
fi
done
}
if [ "$#" -eq 0 ]; then
echo "Usage: $0 <folder_path> [tag_name]"
exit 1
fi
if [ ! -d "$1" ]; then
echo "Error: The provided path is not a valid folder."
exit 1
fi
process_folder "$1" "${2:-"genre"}"