shell/mpd/bin/cleanup-music: fail on error + refactor

This commit is contained in:
Henrik Lissner 2016-12-29 02:39:21 -05:00
parent daec400b02
commit 86fe87369b

View file

@ -3,7 +3,9 @@
# Delete all songs that are in the delete-pls playlist, and cleans up any empty folders # Delete all songs that are in the delete-pls playlist, and cleans up any empty folders
# it leaves behind. # it leaves behind.
playlistfile=$HOME/music/.playlists/delete-pls.m3u set -e
playlistfile=$HOME/music/.db/playlists/delete-pls.m3u
songs=$(<"$playlistfile") songs=$(<"$playlistfile")
# Delete designated songs # Delete designated songs
@ -18,6 +20,5 @@ for song in ${songs[@]}; do
done done
:>"$playlistfile" :>"$playlistfile"
# Remove empty directories in two passes # Remove empty directories
find "$HOME/music" -maxdepth 2 -type d -empty -delete find "$HOME/music" -type d -empty -delete
find "$HOME/music" -maxdepth 1 -type d -empty -delete