Mp3 playlist script – for current directory and sub folders

Making mp3 playlists, a “simple” script

#!/bin/bash

touch ${PWD##*/}.m3u
export IFS=$’n’
for i in $(find $1 -name “*.mp3″ -type f)
do
echo “$i” |sed ’s/..(.*)/1/’ >> ${PWD##*/}.m3u
done

shuf ${PWD##*/}.m3u > ${PWD##*/}2.m3u
shuf ${PWD##*/}2.m3u > ${PWD##*/}.m3u
rm ${PWD##*/}2.m3u

You can leave out the last three lines if you don’t want to shuffle the list.

There is probably improved/easier code than this but it works for me.

To use, simply copy the code into a text file, save with a name of your choice, and make the file script executable. Put the file in your path, and then run in the directory you want to make a playlist from. it will work on all sub directories of that folder.

Leave a Reply

Your email address will not be published. Required fields are marked *