Skip to content

Instantly share code, notes, and snippets.

@christianmondabon
Created May 2, 2019 10:55
Show Gist options
  • Save christianmondabon/224741f16e78099c5db456cf8629c2f1 to your computer and use it in GitHub Desktop.
Save christianmondabon/224741f16e78099c5db456cf8629c2f1 to your computer and use it in GitHub Desktop.
Delete previously synced files which are not on a YouTube playlist anymore (see youtube-playlist-sync project)
#!/bin/bash
/usr/local/bin/youtube-dl -j --flat-playlist --restrict-filenames "YOUTUBE-PLAYLIST-URL" | cut -d'"' -f4 | xargs -I "{}" -n 1 find FILELOCATION -type f -name '*{}*' | sort | comm -23 <(find $FILELOCATION -type f | sort) - | grep -v yps.json | xargs -I "{}" rm '{}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment