Last active
January 26, 2025 05:56
-
-
Save hiqua/698702e2ee4a5da44d91c848c2c65d56 to your computer and use it in GitHub Desktop.
Delete duplicates from mpd playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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