/usr/bin/mpgenplaylists is in mpdtoys 0.25.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #!/bin/sh
set -e
conf=/etc/mpd.conf
if [ -e $HOME/.mpdconf ]; then
conf=$HOME/.mpdconf
fi
if [ ! -e $conf ]; then
echo "error: $conf does not exist" >&2
exit 1
fi
music_directory=$(grep "^music_directory" $conf | cut -d '"' -f 2 | sed -e "s!^\~!$HOME!")
playlist_directory=$(grep "^playlist_directory" $conf | cut -d '"' -f 2 | sed -e "s!^\~!$HOME!")
if [ -z "$music_directory" ] || [ -z "$playlist_directory" ]; then
echo "error: failed to parse $conf" >&2
exit 1
fi
if [ ! -d "$music_directory" ] || [ ! -d "$playlist_directory" ]; then
echo "error: both $music_directory and $playlist_directory need to exist" >&2
exit 1
fi
rm $playlist_directory/\ *.m3u 2>/dev/null || true
IFS="
"
for dir in $(cd "$music_directory"; find -type d -follow | sed 's!^./!!'); do
playlist="$(echo "$dir" | tr "_" " " | sed 's!/! - !g')"
if [ "$playlist" = . ]; then
playlist=all
fi
find "$music_directory/$dir" -type f -follow | sort \
> "$playlist_directory/ $playlist".m3u
done
exit
<<POD
=head1 NAME
mpgenplaylists - generate mpd playlists for each subdirectory of music
=head1 SYNOPSIS
mpgenplaylists
=head1 DESCRIPTION
B<mpgenplaylists> generates mpd playlists.
It reads your ~/.mpdconf or /etc/mpd.conf to figure out where mpd keeps its
music directory and playlist directory.
For each subdirectory of the music directory, a playlist is generated in the
playlist directory. The playlists created by this tool always start with a
space to avoid conflicts with your manually created playlists.
So if you keep your sound in Artist/Album/ directories, you'll get playlists
named like " Artist - Album", and also playlists named just " Artist" that
contain all music by that artist. An " all" playlist is also created, that
contains all your music.
Each time it's run it updates the playlists, and removes any obsolete ones
that it created before.
=head1 LIMITATIONS
It does not currently sort songs in an album by track number, but instead
sorts by filename.
=head1 AUTHOR
Copyright 2007 Joey Hess <joey@kitenet.net>
Licensed under the GNU GPL version 2 or higher.
http://kitenet.net/~joey/code/mpdtoys
=cut
POD
|