NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Windows v
« Previous 1 2 3 4 5 … 101 Next »
NPVR Windows recordings folder cleanup....

 
  • 0 Vote(s) - 0 Average
NPVR Windows recordings folder cleanup....
Colincam
Offline

Junior Member

United States
Posts: 30
Threads: 9
Joined: Mar 2023
#1
2024-01-06, 12:36 PM (This post was last modified: 2024-01-06, 01:43 PM by Colincam.)
I use Plex to watch TV shows recorded by NextPVR.  When done with the recordings, I will delete them via Plex.  This leaves behind orphaned metadata.  I wanted a routine to clean up the NextPVR recordings folder, delete orphaned NextPVR metadata and if that leaves an empty folder, delete the empty folder as well.   So, I asked AI to help me create a batch file to perform these duties.  I then set a task in Windows Task Scheduler to run this batch file daily.  Below is the batch file created with the help of AI.  Please note that you use this batch file AT YOUR OWN RISK.  Please backup your recordings folder before applying this process.  It WILL delete any files that do not have a related file with a .ts file extension.  If there is a .ts file, it will leave it and its associated metadata alone.  If you have any .mp4's for instance in the NextPVR recordings folder, they will also be deleted since they have no .ts file associated with them.  This script assumes that you use the NextPVR recordings folder only for NextPVR recordings with the .ts file extension.  Please replace the set command at the beginning to point to YOUR recordings folder.  What you see is mine as an example.  Do not put this batch file in the recordings folder itself for it will delete itself.  No warranty is implied, use at your own risk.  You can copy and paste into your favorite text editor.  Make the set command change to reflect your recordings folder and save as a batch (.bat) file.  Again, do NOT place the batch file in the recordings folder....

@echo off
set "folder_path=D:\Recorded TV\"

for /r "%folder_path%" %%F in (*) do (
    if "%%~xF" neq ".ts" (
        if not exist "%%~dpnF.ts" (
            del "%%F"
            echo Delete: "%%F"
        )
    )
)

for /d /r "%folder_path%" %%d in (*) do (
    dir /b "%%d" 2>nul | findstr "^" >nul || (
        rd "%%d"
        echo Deleted empty subfolder: "%%d"
    )
)
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,970
Threads: 956
Joined: May 2006
#2
2024-01-06, 02:49 PM
NextPVR will automatically delete files and metadata if the source file is deleted. If you are converting files to mp4 add mp4 to extension list show here https://forums.nextpvr.com/showthread.ph...#pid588295 It will also remove empty folders.

You should also use NScripthelper or NextTool to rename the file in the NextPVR database to mp4 (since I assume) that is the file you delete in Plex and why files are left in the first place.

Martin
Colincam
Offline

Junior Member

United States
Posts: 30
Threads: 9
Joined: Mar 2023
#3
2024-01-06, 03:27 PM
(2024-01-06, 02:49 PM)mvallevand Wrote: NextPVR will automatically delete files and metadata if the source file is deleted.  If you are converting files to mp4 add mp4 to extension list show here https://forums.nextpvr.com/showthread.ph...#pid588295  It will also remove empty folders.

You should also use NScripthelper or NextTool to rename the file in the NextPVR database to mp4 (since I assume) that is the file you delete in Plex and why files are left in the first place.

Martin
I have two NPVR servers (latest versions V6) and neither of them automatically delete metadata files when the source .ts file was deleted out from under them by Plex.  I had lots of leftover files and folders.  No mp4's going on.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,970
Threads: 956
Joined: May 2006
#4
2024-01-06, 03:31 PM (This post was last modified: 2024-01-06, 03:35 PM by mvallevand.)
Right, I was thinking deleting from the NextPVR database not the files from the folder sorry about that. It is probably something that sub could look at auotmating now that there is a lot of kruft for non-NextPVR users.

If you aren't using timing or thumbnails, you should turn them off. External xml files can also be disabled so I think you will only be left with the empty folder issue which could be considered a Plex bug too.

Martin
Colincam
Offline

Junior Member

United States
Posts: 30
Threads: 9
Joined: Mar 2023
#5
2024-01-07, 04:16 PM
(2024-01-06, 03:31 PM)mvallevand Wrote: Right, I was thinking deleting from the NextPVR database not the files from the folder sorry about that.  It is probably something that sub could look at auotmating now that there is a lot of kruft for non-NextPVR users.

If you aren't using timing or thumbnails, you should turn them off.  External xml files can also be disabled so  I think you will only be left with the empty folder issue which could be considered a Plex bug too.

Martin
I do occasionally use the NextPVR clients and Kodi so I do enjoy the NextPVR metadata.  However, I have a user that prefers Plex and wants to be able to delete recordings from Plex that are no longer needed.  But, as stated above, when an app such as Plex deletes a recording, it has no knowledge of all of the NextPVR generated metadata and as such, leaves several files behind.  So, the recordings folder was becoming "messy."  Since it took considerable effort to create the above solution via a batch file, I thought I would share it, in case someone else uses Plex to view NextPVR created recordings and then deletes them.  I do realize that if a recoding is deleted via the NextPVR database, it will take care of the cleanup.  This is to help folks who have an app such as Plex that deletes the recording with no knowledge of NextPVR.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,970
Threads: 956
Joined: May 2006
#6
2024-01-07, 04:25 PM (This post was last modified: 2024-01-07, 04:31 PM by mvallevand.)
It's great to share but I do think sub needs to look into the automatic delete too because in my testing yesterday it wasn't working as designed for remote deleting (as in from Plex) I have the following settings and the only way I could trigger anything was when trying to play a file that wasn't there and it left everything but the the database record. Restarting the server didn't do anything, maybe there is another trigger?

Code:
.
    <AutoRemoveMissingRecordings>true</AutoRemoveMissingRecordings>
    <CheckForRenamedRecordings>true</CheckForRenamedRecordings>
    <NoRemoveWhenTreeMissing>true</NoRemoveWhenTreeMissing>

The metadata comes from the database anyway and Kodi doesn't use thumbnail or timing files.

Martin
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,729
Threads: 767
Joined: Nov 2003
#7
2024-01-07, 04:35 PM
NextPVR only tries to delete these extra files when you explicitly tell NextPVR to delete a recordings.

AutoRemoveMissingRecordings etc, will only remove the entry from the database. NextPVR isn't a fan of deleting files unless it has been explicitly told to.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,970
Threads: 956
Joined: May 2006
#8
2024-01-07, 04:49 PM
Ok I understand better now I am pretty sure in the past NextPVR automatically removed files that I didn't ask to delete.

I disagree that timing and thumbnail files should be left around around afterwards those are custom formats.

Martin
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,729
Threads: 767
Joined: Nov 2003
#9
2024-01-07, 05:06 PM
(2024-01-07, 04:49 PM)mvallevand Wrote: Ok I understand better now I am pretty sure in the past NextPVR automatically removed files that I didn't ask to delete.
I'm sure it's never tried to delete these other associated files when it's noticed the recording file does not exist.

It seems reasonable though, and it already had code to take care of this, so I've enabled it for the next release.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,970
Threads: 956
Joined: May 2006
#10
2024-01-07, 05:09 PM
I wasn't meaning the extra files, NextPVR wasn't deleting rows from the database either and I am sure in testing that has happened to me before, one reason that the missing tree setting became important.

Martin
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (3): 1 2 3 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  Series Recordings - Bug? MalcolmInman 32 951 2025-05-31, 01:52 AM
Last Post: mvallevand
  Pending recordings not showing in web interface and NextPVR gadget not working... henryixV 4 276 2025-05-27, 08:29 PM
Last Post: henryixV
  Since v7: EPG mostly "no listings", and channels change during recordings :'( rightbryce 38 3,510 2025-05-19, 03:18 PM
Last Post: erik123
  Failed recordings "Operation timed out" Stanno 8 507 2025-04-27, 07:26 PM
Last Post: Nick017
  Can't delete scheduled recordings Druhl 3 220 2025-04-22, 09:10 PM
Last Post: mvallevand
  Manual Recurring Recordings jcole998 3 242 2025-04-17, 09:10 PM
Last Post: mvallevand
  Portions of recordings are missing MovieBuff 6 528 2025-04-14, 03:15 PM
Last Post: MovieBuff
  Recordings not displaying Jakesty 4 283 2025-04-12, 01:15 PM
Last Post: mvallevand
  Windows 24H2 - Can't install Hauppage Drivers Lao Pan 6 1,432 2025-04-04, 04:49 AM
Last Post: seattlefog
  Scheduled Late Night through-midnight recordings suddenly stop at midnight Andre_Mikulec 4 389 2025-03-29, 12:56 AM
Last Post: mvallevand

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode