I’m a big fan of movies and series and use a combination of Couchpotato, Sickbeard & Sabnzbd to download. Then, I feed everything to Plex which adds meta-data, makes it look pretty and available on my Apple TV to watch. Works like a charm.
What annoyed me, was that when I deleted a movie with the Plex GUI, it just deletes the media-file (e.g. just the .mkv or whatever) but leaves all the surrounding trash and the folder which contained the file as well.
So I created a few one-liners to ‘find’ the trash, delete it, and finally delete the empty folders.
Also, you must enable, or allow ‘media deletion’ on your plexmediaserver (it’s a setting in ‘Settings -> Server -> Library) but after that I experienced that the tools I use for downloading and the Plex-clients use different permissions (so I ended up with a Plex-client that does not have the right permissions to delete the files.)
Warning: it’s not pretty, this should probably be done in a nice little script and can be done much more clean, but this was a quick hack and I want the syntax to be here for future reference, so don’t bash me for that 🙄.
Example to correct the permissions (bad hack!) & find all the garbage-files recursively in the media folders and zap them to oblivion:
@daily sudo chmod -R 777 /media/media @daily sudo find /media/media -name "*.nzb" -type f -delete @daily sudo find /media/media -name "*.idx" -type f -delete etc ..
Then when you cleaned out the folders, you can (at your own risk ofcourse) safely use:
@daily sudo find /media/media -type d -empty -delete
which will ‘find’ things with ‘type d’ (that are directories ;) ) which are ‘-empty’ and deletes ’em.
A nice and clean media library! Hurray!