Skip to content

Instantly share code, notes, and snippets.

@demonbane
Created February 5, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demonbane/7c227c6a696229a68c6f098fe7e91b5d to your computer and use it in GitHub Desktop.
Save demonbane/7c227c6a696229a68c6f098fe7e91b5d to your computer and use it in GitHub Desktop.
Delete directory after Radarr import
#!/usr/bin/env bash
# log all output from here on out to a log file. Comment this line out if testing from command-line
exec >> /path/to/store/log-file
printf '\nclean-radarr-import.sh called at %b\n\n' "$(date)"
# For debugging, print every radarr environment variable passed to the script
# if you don't want it, just delete these 3 lines
for i in ${!radarr*}; do
printf '%b="%b"\n' "$i" "${!i}"
done
if [ "${radarr_eventtype}" = "Download" ]; then
printf 'Processing "%b"...\n' "${radarr_moviefile_sourcefolder}"
# no rush, make sure there's plenty of time for any Radarr actions to finish
sleep 10
if [ -d "${radarr_moviefile_sourcefolder}" -a ! -f "${radarr_moviefile_sourcepath}" ]; then
printf 'Removing "%b"... ' "${radarr_moviefile_sourcefolder}"
rm -rv "${radarr_moviefile_sourcefolder}"
else
printf 'Tests failed\n'
ls -alh "${radarr_moviefile_sourcefolder}"
fi
fi
printf '=%.0s' {1..45}
printf '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment