Last active
October 12, 2022 01:14
-
-
Save subzero79/87a347a07964390884c9 to your computer and use it in GitHub Desktop.
Sonarr post processing script to clean video files if the source is rar (packed) content
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
#!/bin/bash | |
#sonarr_episodefile_sourcefolder="/torrent/finish/tv-sonarr/Penny.Dreadful.S01E01.720p.HDTV.x264-2HD" | |
#sonarr_episodefile_sourcepath="/torrent/finish/tv-sonarr/Penny.Dreadful.S01E01.720p.HDTV.x264-2HD/penny.dreadful.s01e01.720p.hdtv.x264-2hd.mkv" | |
sonarr_label="tv-sonarr" | |
base_dir=$(basename $sonarr_episodefile_sourcefolder) | |
if [ "${base_dir}" == "${sonarr_label}" ];then | |
echo "Single file torrent" | |
exit | |
fi | |
find $sonarr_episodefile_sourcefolder -name \*.r[0-9][0-9] | egrep '.*' &>/dev/null | |
case $? in | |
0) | |
echo "Rar files present, deleting video files" | |
echo `rm -rv "${sonarr_episodefile_sourcepath}"` | |
;; | |
*) | |
echo "No rar files, nothing to clean" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wish I'd realized you could fork a gist, but I suggest
-iregex '.*\.r[0-9a][0-9r]$'
for your find argument. It accounts for (rare) files named likepart01.rar
as well as numbered.r00
files. Though I suppose it could choke if the movie isn't really rar'd, but instead comes w/ a small.rar
file for some reason.My version: https://gist.github.com/fryfrog/94716e7e27ba38dff57c7631d9f58bed