From 303aa81d25df5f96ce980f2d38efb4a8ffc8faf7 Mon Sep 17 00:00:00 2001 From: tdback Date: Mon, 27 Jan 2025 22:45:38 -0500 Subject: initial commit --- mpc_update | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 mpc_update (limited to 'mpc_update') diff --git a/mpc_update b/mpc_update new file mode 100755 index 0000000..f576097 --- /dev/null +++ b/mpc_update @@ -0,0 +1,25 @@ +#!/bin/sh + +# mpc_update: Update an mpd playlist to include new songs in the music +# directory. + +die() { echo "$0: $*" >&2; exit 1; } +try() { "$@" || die "cannot $*"; } + +[ "$#" -ne 2 ] && die "usage: mpc_update " + +PLAYLIST="$1" +MUSIC_DIR="$2" + +[ -d "$MUSIC_DIR" ] && cd "$MUSIC_DIR" || + die "music directory '$MUSIC_DIR' does not exist!" + +# Clear the current playlist to prevent song duplication in mpd. +[ -e "$HOME/.local/share/mpd/playlists/${PLAYLIST}.m3u" ] && + try mpc clear >/dev/null && + try mpc rm "$PLAYLIST" + +# Add every song in the music directory. +try mpc add -- * + +try mpc save "$PLAYLIST" -- cgit v1.2.3