NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 42 43 44 45 46 … 93 Next »
AutoDelete (Delete old recordings to make room for new ones as disk space gets low)

 
  • 0 Vote(s) - 0 Average
AutoDelete (Delete old recordings to make room for new ones as disk space gets low)
lopazopy
Offline

Member

Posts: 51
Threads: 9
Joined: Dec 2005
#1
2006-03-07, 01:22 PM
I had a very good friend of mine to come up with a vbscript that will delete the oldest recordings when you get low on hard drive space (I'm working with a 40 GB hard drive on my laptop here). He didn't want to mess with the plugin interface because he's never used Gbpvr and said that this would be much easier. He calls the the vbscript in PostProcessing.bat and the script determines how much free space you have on a drive, determines if you've reached the predetermined low disk space level, and then deletes the oldest file created in a predetermined directory. I've included the PostProcessing.bat and the AutoDelete.vbs. Please let me know what you think and if you know of any problems that I might come across. Also, if anyone wants to make it a plugin or has any suggestions on how it could be better, please go ahead and see what you can do with it.

(Also, I didn't want to use MaxRecordings because if I take this route and I end up keeping 3 recordings for every episode. What happens when my list of reoccurring recordings gets too big for my hard drive to keep 3 episodes each? I wanted it to be like his tivo, but maybe I will use a combination of the two to catch those shows that decide to have an all day marathon.)

PostProcessing.bat
Code:
cscript AutoDelete.vbs

AutoDelete.vbs
Code:
' True means no deletes will take place Const SAFE_MODE = True ' Minimum amount of free space or else we delete (in GB) Const MIN_FREE_SPACE = 1.5 ' Drive to check free space on Const DRIVE = "C:" ' Path to media directory Const MEDIA_PATH = "C:\MyVideos" ' ******************************************************** Dim fso Set fso = CreateObject("Scripting.FileSystemObject") AutoDelete() Sub AutoDelete() Dim freeSpace Dim fso Dim fileArr Dim delIndex freeSpace = GetFreeSpace() If freeSpace < MIN_FREE_SPACE Then fileArr = GetFiles() delIndex = 0 Do While freeSpace < MIN_FREE_SPACE And delIndex < UBound(fileArr) freeSpace = freeSpace + BToGB(fileArr(delIndex).Size) Delete(fileArr(delIndex)) delIndex = delIndex + 1 Loop End If End Sub Function BToGB(bytes) BToGB = bytes / 1024 / 1024 / 1024 End Function Function GetFreeSpace() GetFreeSpace = BToGB(fso.GetDrive(DRIVE).FreeSpace) End Function Function GetFiles Dim fileArr() Dim folder Dim fileCount Set folder = fso.GetFolder(MEDIA_PATH) fileCount = 0 For Each fo In folder.SubFolders fileCount = fileCount + fo.Files.Count Next ReDim fileArr(fileCount - 1) i = 0 For Each fo In folder.SubFolders For Each fi In fo.Files Set fileArr(i) = fi i = i + 1 Next Next QuickSort fileArr, LBound(fileArr), UBound(fileArr) GetFiles = fileArr End Function Sub Delete(file) If SAFE_MODE Then MsgBox("AutoDelete: " & file.Name & vbCrLf & "Created: " & file.DateCreated & vbCrLf & "Size: " & BToGB(file.Size) & "GB") Else File.Delete End If End Sub Sub QuickSort(Arr, First, Last) Dim Pivot If First < Last Then Pivot = Partition(Arr, First, Last) QuickSort Arr, First, Pivot - 1 QuickSort Arr, Pivot + 1, Last End If End Sub Function Partition(Arr, First, Last) Dim x, i, j Dim swap Set x = Arr(First) i = First + 1 j = Last Do While i <= j Do While i <= j If Arr(j).DateCreated <= x.DateCreated Then Exit Do j = j - 1 Loop Do While i <= j If Arr(i).DateCreated > x.DateCreated Then Exit Do i = i + 1 Loop If i < j Then Set swap = Arr(i) Set Arr(i) = Arr(j) Set Arr(j) = swap i = i + 1 j = j - 1 End If Loop Set Arr(First) = Arr(j) Set Arr(j) = x Partition = j End Function
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#2
2006-03-24, 08:15 PM
been thinking about making one of these myself,as the max recordings feature doesn't work the way i'd like..[doesn't keep the 'newest' xx shows,just that many total]

hmm,a couple changes i'd like to see, ability to move instead of delete..kinda like a trashbin, allows possibility to archive to removeable media later..Smile [much needed]

and maybe some way to act differently on different subdirectories?
[maybe like putting an .ini in certain dir that would change settings? or an exclude]

guess i could always just edit it myself...lol
but really the move thing would be enough for me to start using it Big Grin
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 108,484
Threads: 784
Joined: Nov 2003
#3
2006-03-24, 08:47 PM
Quote:as the max recordings feature doesn't work the way i'd like..[doesn't keep the 'newest' xx shows,just that many total]
What do you mean? It does keep the newest xx shows. If I schedule it to keep 3 episodes of 'Lost' it'll always be the last three episodes broadcast.
erik
Offline

Posting Freak

Posts: 1,143
Threads: 124
Joined: Apr 2005
#4
2006-03-24, 09:48 PM
When you search the forum for purge.bat you will find another solution for this.
P4 3GHz 1GB, 250GB, nVidia dualTV, GBPVR 1.3.11, XP
Support Comskip, visit the forum and donate at http://www.comskip.org/
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#5
2006-03-26, 08:01 PM
really? hmmm,hasn't been my exprience..i have a couple re-occurring shows that haven't recorded new ones for ages since the max was reached..maybe a problem with my schedule or may be duplicates...[been a while since i checked to make sure show timeslot didn't change,etc.]
and this script deletes based on age and space free,which is really what i wanted..Smile
no complaints Sub..just wanted to keep some emergency space free and possibly use this for archiving old stuff..Smile
i have a feeling my problem is in my schedule..[why it hasn't made any new ones lately..]

what happens if you already have say 6 recordings and tell it to keep only 5? will it automatically delete the oldest 1? i think that may be what happened..
maybe because i already had more than the max when it goes to record a new one is what's confusing it? [it would have to delete 2 or more shows before making a new one to stay under max]
any thoughts?
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 108,484
Threads: 784
Joined: Nov 2003
#6
2006-03-26, 08:09 PM
Quote:really? hmmm,hasn't been my exprience..i have a couple re-occurring shows that haven't recorded new ones for ages since the max was reached..
It works well. I use it for pretty much all my recordings. I've not seen any other reports of it not working.

Quote:what happens if you already have say 6 recordings and tell it to keep only 5? will it automatically delete the oldest 1? i think that may be what happened..
maybe because i already had more than the max when it goes to record a new one is what's confusing it? [it would have to delete 2 or more shows before making a new one to stay under max]
any thoughts?
It only applies to shows made as part of the same season recording. If you already have shows sitting around with the same name (made as part of a different/earlier season recording), these will be left alone.

If you tell it you only want five recordings, it'll keep the most recent five - deleting any older ones.
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#7
2006-03-26, 09:00 PM
that must be it then...i had to re-schedule those after an update and already had several recordings from the previous scheduling...[which was obviously different as i had to re-create them]
i was wondering what was goin on there,i use it on all my recordings too and only had problems with a couple of old ones...thanx Smile
everything's been working so well since last few updates i'm really enjoying it without having to peek under the hood much anymore..Wink
Beers Cheers!
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
lopazopy
Offline

Member

Posts: 51
Threads: 9
Joined: Dec 2005
#8
2006-09-14, 11:22 PM
I added this utility to the wiki, here.
alexeyalexey
Offline

Junior Member

Posts: 15
Threads: 4
Joined: Sep 2004
#9
2007-07-05, 06:46 AM
http://forums.nextpvr.com/showthread.php...spacewatch

screenshot appended
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Import/export recordings via API? whurlston 4 4,867 2019-02-19, 11:48 AM
Last Post: Graham
  Conflict recordings scJohn 1 3,280 2018-03-23, 07:43 PM
Last Post: sub
  API / web call for setting recordings Pbathuk 2 4,198 2018-01-13, 05:17 AM
Last Post: Pbathuk
  Tuner status & disk usage mikaelgu 2 3,676 2017-04-10, 04:51 PM
Last Post: mikaelgu
  API access to artwork and deleting recordings cncb 29 19,786 2016-11-06, 02:20 AM
Last Post: mvallevand
  How to move recordings without them getting deleted from db drmargarit 4 5,021 2015-09-27, 05:33 PM
Last Post: sub
  Best approach to creating recurring recordings from c# drmargarit 0 3,243 2015-09-27, 01:32 AM
Last Post: drmargarit
  Changing the recording priority on recurring recordings cbgifford 4 5,173 2014-08-17, 03:13 PM
Last Post: Kiwi
  Time to make Touch web Service less experimental fred250 106 41,104 2014-06-15, 09:13 PM
Last Post: fred250
  How does NextPVR group recordings for XBMC? spinnaker 2 3,249 2013-11-21, 01:33 AM
Last Post: spinnaker

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

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

Linear Mode
Threaded Mode