NextPVR Forums

Full Version: updated recoverrecordings.bat
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I updated the RecoverRecordings.bat file for the changes in newer versions.
[had to take out redundant first line of xml]
if you use a ntfs recording drive and lose your database,this can build a recording-dump.xml you can import back in by looking at the show:metadata.xml file attached on each...

To use: just stick it in your recordings dir and run it..it will create a recordings-dump.xml in that dir that you can then import from config.exe or command line pvrx2.
Checks for any files with metadata,.mpg,.ts.avi.wmv

fairly simple and foolproof....lol Big Grin
Enjoy!
Code:
@echo off
set out=%~dp0
echo.
echo. Generating Recording Import data for all recordings in %out% to
echo.     %out%\recording-dump.xml
echo.

FOR /F "tokens=*" %%i IN ("<?xml version="1.0" encoding="UTF-8"?>") DO ECHO %%i> "%out%\recording-dump.xml"
FOR /F "tokens=*" %%i IN ("<recordings>") DO ECHO %%i>> "%out%\recording-dump.xml"
FOR /R %out% %%f IN (*.mpg *.ts *.avi *.wmv) DO (call :extract "%%~f")
rem ::    more < %%f:metadata.xml >> "%out%\recording-dump.xml"
FOR /F "tokens=*" %%i IN ("</recordings>") DO ECHO %%i>> "%out%\recording-dump.xml"

echo.
echo Done.
echo.
echo No metadata.xml found attached to above files..all others imported.
pause
notepad.exe %out%\recording-dump.xml
goto :eof

:extract
for /f "usebackq tokens=* skip=1" %%p in ("%~1:metadata.xml") do (
    if "%%p" ==  "<recording>" (
    echo   %%p>>%out%\recording-dump.xml
    ) else (
        if "%%p" ==  "</recording>" (echo    %%p>>"%out%\recording-dump.xml") else (
        echo          %%p>>"%out%\recording-dump.xml")
                 )
)
goto :eof
also can be run from a net dir..still trying to figure out how to alter the path to net paths while i import..maybe soon..Wink [convert e:\mpg to \\server\share]
Fixed: paths with spaces now corrected..
Very nice file :-)
Just what I needed ... after forgetting to do backups.
Do you have more useful BAT files?
sure i do...Big Grin tried the super simple archiver? used to keep up with my dvdburner batch file but there are better alternatives out there nowdays..

i did make a couple to clean out the db but still need some work..

oh and recordingstatus.bat that spits out same info as tray app for my vfd display..
[tho i use it with smartielcd and a helper app too]

also made a 'sendshow.bat' to send show info to another gbpvr as it's recorded..
[tho easier now to just do a pvrx2 -import:"file.xml" from the other machine]

plus in this thread there are a couple more:
http://forums.nextpvr.com/showthread.php?t=20995
like formatting an email with pending recordings, lookup of show info,etc..
would like to add new ones to that thread if you have any to add..Smile

i you need any help with batches i'm glad to help..Big Grin
with a little creative thinking there's little [logic-wise] you can't do with a batch [specially with for-loops..lol]

here's the tip for the day: wanna search/replace in a variable? use %varConfusedtring=newstring%
so say i have a variable %var% with a value of Thishere
if i reference it with %var:This=Thatt% instead of %var%, reading the variable would produce Thatthere instead of Thishere
note: doesn't work with single % vars like %1 %2

tip#2: alternative ways to remove quotes:
%var:~1,-1% [removes first and last character]
%var:"=% [replaces ALL " with nothing]
Very useful file thanks - or at least it would be if my recordings had any :metadata.xml attached to them!

Does anyone know if GBPVR's transcoding from Mpeg to Xvid (which I have set up to run automatically in the Config / Processing tab) loses this information, and whether there's any way to retain it?

Also, I've attached a copy of the code with minor modifications to include quote marks around the redirection output file strings, so that it will work when there are spaces in the recordings folder name (e.g. "E:\My TV Recordings")

Thanks again for this.

Code:
@echo off
set out=%~dp0
echo %out%
echo.
echo. Generating Recording Import data for all recordings in %out% to
echo.     %out%\recording-dump.xml
echo.

FOR /F "tokens=*" %%i IN ("<?xml version="1.0" encoding="UTF-8"?>") DO ECHO %%i>
"%out%\recording-dump.xml"
FOR /F "tokens=*" %%i IN ("<recordings>") DO ECHO %%i>> "%out%\recording-dump.xml"
FOR /R "%out%" %%f IN (*.mpg *.ts *.avi *.wmv) DO (call :extract "%%~f")
rem ::    more < %%f:metadata.xml >> "%out%\recording-dump.xml"
FOR /F "tokens=*" %%i IN ("</recordings>") DO ECHO %%i>> "%out%\recording-dump.xml"

echo.
echo Done.
echo.
echo No metadata.xml found attached to above files..all others imported.
pause
notepad.exe %out%\recording-dump.xml
goto :eof

:extract
for /f "usebackq tokens=* skip=1" %%p in ("%~1:metadata.xml") do (
    if "%%p" ==  "<recording>" (
    echo   %%p>>%out%\recording-dump.xml
    ) else (
        if "%%p" ==  "</recording>" (echo    %%p>>%out%\recording-dump.xml) else (
        echo          %%p>>%out%\recording-dump.xml)
                 )
)
goto :eof
@pBS - for some reason, GBPVR seems to have lost track of one or two files in my standard TV Recordings directory. If I run recoverrecordings.bat in TV Recordings, will it just import the 'lost' files if I then import it into GBPVR, or will I get duplicates of existing entries?
pBS Wrote:i you need any help with batches i'm glad to help..Big Grin
with a little creative thinking there's little [logic-wise] you can't do with a batch [specially with for-loops..lol]

Hi pBS

I'm finishing the Batch file for the Batch-Installer.
Do you know a way to read the ActiveSkin string from config.xml with DOS commands?

You can download a working "demo" of the Batch-Installer for Photo Screen Saver from my home server....and have a look at the batch files.
http://startop.homeftp.net/Plugin.Batch-Installer.zip
liteswap Wrote:@pBS - for some reason, GBPVR seems to have lost track of one or two files in my standard TV Recordings directory. If I run recoverrecordings.bat in TV Recordings, will it just import the 'lost' files if I then import it into GBPVR, or will I get duplicates of existing entries?


it will make a new recordings-dump.xml that includes all files, but if you import them, i believe it will update existing ones...i never had any duplicates...

serafis: looks liek you missed a couple at the bottom,[Extract] but thanks for pointing that out...Big Grin will fix and test and update main post...

MixMan: haven't looked at the files yet but it'd be pretty hard to extract the info from config.xml with batch,as they use lots of illegal chars that are hard to deal with in dos...
[manly "<>!?@" etc.]
i use a tiny autoit app to extract xml stuff...way easier...
[specially now that it has console app compiling..Smile]
i just write to console and read it in batch with for-loop...
tho it could be done if you can test for a string, or use as delimiter <> etc
i found it choked on the first line usually...
[it's a doozy]
<?xml version="1.0" encoding="UTF-8"?>
[double redirections>< and 2 ?'s, both have special meaning]

only reason mine works is i don't alter the data except to skip a line...
if i peek at the data on the line it chokes..

p.s. sorry i lost this thread on a power outage...lol
MixMan Wrote:Hi pBS

I'm finishing the Batch file for the Batch-Installer.
Do you know a way to read the ActiveSkin string from config.xml with DOS commands?

You can download a working "demo" of the Batch-Installer for Photo Screen Saver from my home server....and have a look at the batch files.
http://startop.homeftp.net/Plugin.Batch-Installer.zip

looked at the batches, best bits i can offer is you can use taskkill.exe [included with all windows's] to kill processes.. [taskkill /f /im "GBPVRtray.EXE"]
and use start instead of run? utility..eg: start "" "%InstallDir%\pvrx2.exe"

AHA...want to read something from the config.xml? here's your line..lol
Code:
for /f "usebackq tokens=1,2,3,* delims=<>" %%f in (`findstr /i  "<ActiveSkin>" config.xml`) do echo %%h
just change the echo to either set a var or whatever..
i forgot i had problems writing back the data, not reading it..lol
[and findstr can be quite handy]
hope that helps...Big Grin
Thanks very much

You can see the final result of the Installer here.
http://gbpvr.com/pmwiki/pmwiki.php/Devel...hInstaller
Pages: 1 2