Auto-delete recordings? Manually filter for ".ts" videos to delete? (Since they're quite large...)

A 1h show in 1080p is around 4GB when recorded from Live TV. It’s awesome to get these recordings, but sometimes I don’t end up watching them, or record a show which doesn’t recur or have a recurring deletion policy, and they’ll float around forever taking a ton of space.

Is there a way to have Plex eventually expire DVR recordings that are not watched? Or to expire them shortly after being watched? Or, is there even a way to view all recorded shows/videos at once (outside of the “DVR Schedule” which doesn’t go back very far)?

When a recording is completed, it is placed in the TV SHOWS library. You can delete them manually or you could edit the show (click on the pencil icon) and on the Advanced tab, select “Delete episodes after playing AFTER A DAY”.
I notice a problem with that option though. If you don’t COMPLETELY watch a show, it will not be deleted. This is a problem because I record and watch the morning news show, but rarely watch to the end. I end up with a bunch of partially watched shows.

To solve this, I wrote a script in Auto-IT to delete shows beyond a specified number and I schedule it to run daily. Here’s the script if you’re interested (you’ll need Auto-IT to tweak and compile it):

;DELOLDSHOWS.AU3 - Created by Terry Wysocki 04/30/2020
;This AUTO-IT script is created to accompany the PLEX media softare and manage multi-episode TV folders.
;It will delete "n" number of old episodes from specified folders limiting them to "n" most recent files.
;It reads the file counts and folder names from deloldshows.ini file in the same folder as the exe.
;Each line in the INI file must contain a number followed by full path of the folder:
;   EXAMPLE:     3 D:\TV\Saturday Night Live
;Note that it will operate on the specified folder AND all folders beneath that independently.
;The ini may have comments starting with a semicolon ;

#include <GuiConstants.au3>
#include <Date.au3>
#include <WinAPIFiles.au3>
#include <array.au3>

AutoItSetOption ( "WinTitleMatchMode", 2 )

$ini='deloldshows.ini'
$f = FileOpen($ini,0)
If $f = -1 Then ;error
	$msg  = 'No deloldshows.ini was found.' & @CR & @CR
	$msg &= 'This program is designed to be used with PLEX and will delete old TV shows beyond a number specified to keep.' & @CR
	$msg &= 'To use: Create an ini file in same folder as the exe with each line '
	$msg &= 'in the form of a number of shows to keep and the full path to the folder.' & @CR
	$msg &= '  EXAMPLE:  3 D:\TV\The Simpsons' & @CR
	$msg &= '(note there is ONE space between the digits (0-999) and the folder path)' & @CR
	$msg &= 'When the program runs, it will read the ini file and delete files in those folders '
	$msg &= 'only keeping the most recent "n" files as specified.' & @CR
	$msg &= '(It will consider only files with mkv,mp4,avi,mpeg,ts extensions)' & @CR
	msgbox(16,'DelOldShows ERROR',$msg)
	Exit
EndIf

;Loop through ini file records
$n=0
$i=0
While True
	$line = FileReadLine($f) ;process each folder:
	If @error = -1 Then ExitLoop
	if stringleft($line,1) = ';' or $line = '' then ContinueLoop
	$n = $n +1
	ConsoleWrite('Line: ' & $line & @CRLF)
	$spacepos = Stringinstr($line,' ')
	$folder= StringMid($line,$spacepos +1)
	$keep = stringleft($line,$spacepos -1)
	if (FileExists($folder)=0) Then ContinueLoop ;folder not present
	if ($keep <0 or $keep >999) Then
		msgbox(16,'ERROR','Invalid data in deloldshows.ini file. Delete ini file and run again for instructions.')
		Exit
	endif
	$Data = _WinAPI_EnumFiles($folder, 1, '*.mp4;*.mkv;*.mov;*.avi;*.ts;*.mpeg;*.vob')

	$numele = $Data[0][0]
	if ($keep >= $numele) then ContinueLoop
	_ArraySort($Data,1,0,0,1)
	$sRange = $numele
	if $keep > 0 then $srange &= ";0-" & $keep -1
	_ArrayDelete($Data, $sRange) ;remove files to be KEPT from the array leaving files to be deleted
	for $i = 0 to Ubound($Data) -1 ;delete each old file
		$pos = StringInStr($data[$i][0],'.',0,-1)
		$filegroup = StringLeft($data[$i][0],$pos) & '*' ;change filename to filegroup.*
		$status = FileDelete($folder & '\' & $filegroup)
		if $status = 0 then
			ConsoleWrite('Delete FAILED: ' & $folder & '\' & $filegroup & @CRLF)
			msgbox(48,'ERROR','Could not delete file' & @CR & $folder & '\' & $filegroup)
		Else
		endif
	Next

WEnd
FileClose($f)
Exit

You can also skip fast forward if your video is still shown as ‘in progress’. As soon as less than 10% of the play tim eremain, the file is considered “watched” by Plex.

Careful with enabling the automatic episode deletion:

If you have separate libraries for bought/ripped series content and series which you have DVR’d, they are still treated as the same show, if you happen to have the same show in both libraries.
What that means is this: if you enable automatic deletion in your DVR library on a certain show, it will also start deleting the episodes of this show in your other series library, if they are marked as “watched”.

Thanks I know how to handle auto episode deletion without issues, my question is more about focusing on the “.ts” files specifically. I’d like any way to sort my library by them, and to have the option to purge them. We could leave the automatic part aside.

If you don’t keep up on it, you could end up with a 4GB or larger file floating around that will never be viewed again. Periodically, I’d like to check which “.ts” files still exist and ensure it’s only ones I want to keep. There’s currently no way to do this.

No way in Plex, that is.
This is done quickly if you access your file storage directly, using whatever means your operating system is offering. Then search for all file names ending in .ts

Thanks for that suggestion, I agree that’s a good workaround for now.

Could we track this as a potential enhancement / feature to add? I think it’d be nice to simply have a view of all recordings – all other DVR services I’ve seen offer this. Plex is unique in that it combines DVR with other videos in the same interface, leading to this issue.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.