Last active
August 29, 2015 13:56
-
-
Save D-32/9161544 to your computer and use it in GitHub Desktop.
Creates a m3u file for each album (a directory). Each mp3 is prefixed with it's position in the playlist: "1 - filename.mp3". The m3u is named like the directory of the album and contains the name of the .mp3 without prefix. The prefix is then removed from every mp3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# file name: "1 - songname.mp3" | |
delimiter="-" | |
delimiter_space=1 #characters after the delimiter until the songname starts | |
find * -type f -name '*.mp3' | while read path; do | |
dir=$(dirname "${path}") | |
filename=${path##*/} | |
cut=$(awk -v a="${filename}" -v b="${delimiter}" 'BEGIN{print index(a,b)}') | |
tmp="${filename%.*}" | |
songname=${tmp:cut+delimiter_space} | |
album=${dir##*/} | |
echo $songname.mp3 >> "$dir/$album.m3u" | |
mv "$dir/$filename" "$dir/$songname.mp3" | |
done | |
echo "finished :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment