From f5c51c712a037c6f453a8021015a327591579115 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 23 Dec 2016 03:10:40 -0500 Subject: [PATCH] Add scripts/cleanup-music.sh --- scripts/cleanup-music.sh | 23 +++++++++++++++++++++++ shell/env.sh | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 scripts/cleanup-music.sh diff --git a/scripts/cleanup-music.sh b/scripts/cleanup-music.sh new file mode 100755 index 00000000..f1148b79 --- /dev/null +++ b/scripts/cleanup-music.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# 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 +songs=$(<"$playlistfile") + +# Delete designated songs +IFS=" +" +for song in ${songs[@]}; do + fpath="$HOME/music/$song" + if [[ -f $fpath ]]; then + echo "Deleting: $song" + rm -f "$fpath" + fi +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 diff --git a/shell/env.sh b/shell/env.sh index 25c4e7c2..89879d9e 100644 --- a/shell/env.sh +++ b/shell/env.sh @@ -1,6 +1,6 @@ # Loaded at the end of the initialization process -export PATH="$DOTFILES/bin:$HOME/bin:$PATH" +export PATH="$DOTFILES/bin:$DOTFILES/scripts:$HOME/bin:$PATH" # export EDITOR=$(is-callable nvim && echo 'nvim' || echo 'vim')