Skip to content

Instantly share code, notes, and snippets.

View D-32's full-sized avatar
:shipit:
Shipping stuff

Dylan Marriott D-32

:shipit:
Shipping stuff
View GitHub Profile
@D-32
D-32 / create_playlist.sh
Last active August 29, 2015 13:56
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.
#!/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)}')