Skip to content

Instantly share code, notes, and snippets.

@hiqua
Last active January 26, 2025 05:56
Show Gist options
  • Save hiqua/698702e2ee4a5da44d91c848c2c65d56 to your computer and use it in GitHub Desktop.
Save hiqua/698702e2ee4a5da44d91c848c2c65d56 to your computer and use it in GitHub Desktop.
Delete duplicates from mpd playlist
mpd_first_duplicate(){
mpc -f "%position% \t %file%" playlist | awk ' {
pos=$1
$1=""
map[$0]=map[$0]+1 ;
if (map[$0] > 1) {
print pos ;
exit
}
}'
}
mpd_delete_duplicates(){
while true; do
item="$(mpd_first_duplicate)"
if [ -z "$item" ]; then
break
fi
mpc del "$item"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment