Skip to content

Instantly share code, notes, and snippets.

@RealLukeManning
Last active March 31, 2020 23:25
Show Gist options
  • Save RealLukeManning/a10ebc8c19ba98e8dad638a1370feb68 to your computer and use it in GitHub Desktop.
Save RealLukeManning/a10ebc8c19ba98e8dad638a1370feb68 to your computer and use it in GitHub Desktop.
Check for unlinked downloads
#!/bin/bash
# A simple shell script to check if all my downloaded items have a hardlink associated with them
# The result will be all *.mkv items that do not have more than 1 file linked to this inode
# This is primarily used in Conjunction with Sonarr and Radarr for downloaded item handling
UNLINKED_DOWNLOADS=`find /mnt/user/Media/downloads/ -type f -links 1 -iname *.mkv`
[ -z "$UNLINKED_DOWNLOADS" ] && echo "All good" || echo "$UNLINKED_DOWNLOADS
To delete all files:
find /mnt/user/Media/downloads/ -type f -links 1 -iname *.mkv -exec rm -i {} \;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment