[mythtv-users] Cleanup recordings not in database

Ramon Hofer ramonhofer at bluewin.ch
Tue Jun 14 15:54:40 UTC 2011


On 06/14/2011 05:45 PM, Ian Clark wrote:
> On 14 June 2011 16:13, Ramon Hofer<ramonhofer at bluewin.ch>  wrote:
>> Hi all
>>
>> I've had some problems with my tuner and was playing around.
>> Now I have restored a database where there are not all recordings - that
>> are on the disk - are in the database.
>>
> I use this, ymmv, you'll need to either make it accept
> username/password or hardcode them into the script like I have (I use
> the defaults so I'm unfussed.)
>
> FWIW I remove the echo from the rm line and just run this, however,
> that's at your own risk. :)
>
> Also, this isn't particularly efficient, but it works.
>
> <-------------------------------------------------------------------------
> mythtv at pvr:~$ cat bin/findorphans.sh
> #!/bin/bash
>
> sql="mysql -umythtv -pmythtv -B -N -e"
> dir="/home/mythtv/tv/"
> tmpfile=`mktemp`
> $sql "select basename from mythconverg.recorded">  $tmpfile
>
> find $dir -name "*.mpg" | while read line
> do
>          file=`echo $line | tr "/" "\n" | tail -1`
>          if [ "`grep $file $tmpfile`" == "" ]; then
>                  echo "$line doesn't exist in the database."
>                  echo rm $line
>          fi
> done
>
> rm $tmpfile
> <-------------------------------------------------------------------------
>

Great, thanks alot!
Exactly what I was looking for :-)


Cheers
Ramon


More information about the mythtv-users mailing list