Skip to content

Instantly share code, notes, and snippets.

@acouvreur
Last active May 21, 2024 14:29
Show Gist options
  • Save acouvreur/25f90a605307705cd71c9399fa7eb5b8 to your computer and use it in GitHub Desktop.
Save acouvreur/25f90a605307705cd71c9399fa7eb5b8 to your computer and use it in GitHub Desktop.
Sync deleted files from Radarr/Sonarr
#!/bin/bash
# Find existing files in download/complete that are not in movies or tvshows.
export DOWNLOAD_FOLDER=path/to/downloads
export MOVIES_FOLDER=path/to/movies
export TVSHOWS_FOLDER=path/to/tvshows
findExistingFile() {
file=$(find $MOVIES_FOLDER/ $TVSHOWS_FOLDER/ -samefile "$1")
if [ -z "$file" ]; then
echo "File \"$1\" is not present in the movies or tvshows folders. Deleting..."
rm "$1"
fi;
}
export -f findExistingFile
find $DOWNLOAD_FOLDER -type f -size +1G -exec bash -c 'findExistingFile "$0"' {} \;
@acouvreur
Copy link
Author

Note that this will also deleted files that are completed but not imported!

This may happen quite often if you're close to full capacity and want to free space for completed downloads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment