Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Script for deleting more than x recorings



Hello,

I wrote a perl script that deletes recordings if you have more than x in
one  directory.  You  can  use  it to have e.g. only one "Tagesschau" or
three "Nano"s as described in earlier mails.

Maybe  someday vdr has this function built in, by then, you can use this
script.

Klaus: You can add the script in the vdr package, if you want to.

Usage:
-------insert this into your /etc/crontab--------
# delete old recordings
30 * * * *     root  /usr/local/bin/vdr-deletemorethan.pl Tagesschau 1
-------insert this into your /etc/crontab--------

This  will "delete" Tagesschau-recordings, if you have more than one. It
only renames the directory to ".del".

The  script  searches  in  the  2  directory  levels (for those who use
automatic "EPG-subdirs").

Please  use  this  script  at your own risk! Test it before using it and
uncomment the necessary lines.

-------deletemorethan.pl-------
#!/usr/bin/perl -w

# deletemorethan.pl (c) 01/2001 by uwe.freese@bigfoot.com

unless (@ARGV == 2) { die "SYNTAX: $0 SUBDIR COUNT" }
($SUBDIR, $COUNT) = @ARGV;

$DIRS = `find /video/$SUBDIR/*.rec -type d`
      . `find /video/$SUBDIR/*/*.rec -type d`;

@DIRSARRAY = split " ", $DIRS;

%DEL = ();

# insert all directorys with it's creation time in a hash

foreach $d (@DIRSARRAY) {
  @filestat = stat $d;
  $time = $filestat[9];
  $DEL{$time} = $d;

  # uncomment for testing
  # print $time . " - " . $d . "\n";
}

# sort hash

for $d (sort { lc($b) cmp lc($a) } keys %DEL) {
  if ($COUNT > 0) {
    $COUNT--;
  } else {
    $newname = $oldname = $DEL{$d};
    $newname =~ s/.rec$/.del/;

# uncomment one of these lines

#    print "Rename $oldname to $newname\n";
#    rename $oldname, $newname;
  }
}
-------END of deletemorethan.pl-------

Bye, Uwe.




Home | Main Index | Thread Index