Skip to content

Instantly share code, notes, and snippets.

@jrgutier
Created February 19, 2019 06:34
Show Gist options
  • Save jrgutier/1d850f795f33b3bf3a8923ae677baa1a to your computer and use it in GitHub Desktop.
Save jrgutier/1d850f795f33b3bf3a8923ae677baa1a to your computer and use it in GitHub Desktop.
Clean download directory of Download Station to match what exists in the client
#!/bin/bash
DOWNLOAD_DIR="/volume1/media/downloads/"
COMMAND="find $DOWNLOAD_DIR -maxdepth 1 ! -path '$DOWNLOAD_DIR' ! -name '@eaDir'"
IFS=$'\n'; for i in $(psql -t -A -U postgres -d download -c "SELECT filename from Download_queue"); do COMMAND="$COMMAND ! -name '$i'"; done
COMMAND="$COMMAND -exec rm -rf {} \;"
eval $COMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment