From 86fe87369b452b78b3027c420df8843707cc0f30 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 29 Dec 2016 02:39:21 -0500 Subject: [PATCH] shell/mpd/bin/cleanup-music: fail on error + refactor --- shell/mpd/bin/cleanup-music | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/mpd/bin/cleanup-music b/shell/mpd/bin/cleanup-music index f1148b79..27261f64 100755 --- a/shell/mpd/bin/cleanup-music +++ b/shell/mpd/bin/cleanup-music @@ -3,7 +3,9 @@ # Delete all songs that are in the delete-pls playlist, and cleans up any empty folders # it leaves behind. -playlistfile=$HOME/music/.playlists/delete-pls.m3u +set -e + +playlistfile=$HOME/music/.db/playlists/delete-pls.m3u songs=$(<"$playlistfile") # Delete designated songs @@ -18,6 +20,5 @@ for song in ${songs[@]}; do done :>"$playlistfile" -# Remove empty directories in two passes -find "$HOME/music" -maxdepth 2 -type d -empty -delete -find "$HOME/music" -maxdepth 1 -type d -empty -delete +# Remove empty directories +find "$HOME/music" -type d -empty -delete