From c45193e8d72a20c00b164592f741501fdc648016 Mon Sep 17 00:00:00 2001 From: iAmInAction <83808704+iAmInActions@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:27:17 +0000 Subject: [PATCH] Add sort-mp3s Simple MP3 sorter based on mp3 tags. --- sort-mp3s.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sort-mp3s.sh diff --git a/sort-mp3s.sh b/sort-mp3s.sh new file mode 100644 index 0000000..fa6e410 --- /dev/null +++ b/sort-mp3s.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +TARGET="/path/to/destination" # Specify the target directory where files should be moved + +find . -type f -name "*.mp3" -print0 | while IFS= read -r -d $'\0' file; do + artist=$(ffprobe -loglevel error -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 "$file") + album=$(ffprobe -loglevel error -show_entries format_tags=album -of default=noprint_wrappers=1:nokey=1 "$file") + track=$(ffprobe -loglevel error -show_entries format_tags=track -of default=noprint_wrappers=1:nokey=1 "$file") + title=$(ffprobe -loglevel error -show_entries format_tags=title -of default=noprint_wrappers=1:nokey=1 "$file") + filename=$(basename "$file") + + # Prepare destination directory path + destination="$TARGET/$artist/$album" + mkdir -p "$destination" + + # Move the file to the destination + mv "$file" "$destination/$track"_"$title.mp3" +done