NextPVR Forums

Full Version: Imagegrablite - get it to (re)run on all oid's in database as a batch?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there any way to get Imagegrablite to do this?

i.e. get it to run or rerun on all oid's in database as a batch?

Cheers

k.
Try this,
  • Copy below block into a text file. Name it GetIGL.cmd
  • Review the bolded entries, make sure they match your locations
  • Review the IGL parameters, Make sure they match your needs.
  • Run it!


Code:
@Echo off
:BEGIN

[B]    SET SQLITE="c:/users/public/NPVR/Scripts/Utilities/sqlite3.exe"
    SET DB="c:/Users/Public/NPVR/npvr.DB3"
    SET IGLite="c:/program files/npvr/ImageGrabLite.exe"[/B]

    SET SQL=Select oid, filename from SCHEDULED_RECORDING WHERE status=2;

    ::-----------------------------------------------------------
    :: Generate the SQL script response file
    Echo .echo off                               >  sqlscript.scr
    Echo .output stdout                         >> sqlscript.scr
    Echo %SQL%                                  >> sqlscript.scr

    ::@ECHO ON
    :: type sqlscript.scr
    ::-----------------------------------------------------------
    :: Execute the script
    %SQLITE% %DB% < sqlscript.scr > tmp.fil
    @ECHO OFF

    for /f "tokens=1,2 delims=|" %%a in (tmp.fil) do Call :GetIGL_Data %%a "%%b"
    GoTo :ENDJOB


:GetIGL_Data
    Set oid=%1
    Set fileName=%2
    Echo Getting IGL Data for:
    Echo    OID: %oid%  - FileName: %fileName%
[B]    %IGLite% --oid %oid% --rename --zap2it[/B]
    Echo.
    GoTo :EOF
    
:ENDJOB
    Echo.
Even better, from another post, build the target batch file right from the SQL execution as in this example-

Code:
@Echo off
:BEGIN
    SET SQLITE="c:/users/public/NPVR/Scripts/Utilities/sqlite3.exe"
    SET DB="c:\Users\Public\NPVR\npvr.DB3"
    SET IGLite="c:/program files/npvr/ImageGrabLite.exe"

    SET SQL=SELECT '%IGLite% --nfo --zap2it --oid ', oid ^
            FROM Scheduled_Recording WHERE status=2 AND filename NOT LIKE '%.S%';

    ::-----------------------------------------------------------
    :: Generate the SQL script response file
    Echo .echo off         >  sqlscript.scr
    Echo .mode columns    >> sqlscript.scr
    Echo .output stdout   >> sqlscript.scr
    Echo %SQL%              >> sqlscript.scr
    
    ::-----------------------------------------------------------
    :: Execute the script
    Echo @Echo on                  > GetIGL_Generated.cmd
    %SQLITE% %DB% < sqlscript.scr >> GetIGL_Generated.cmd
    Echo.
    SET /P runIt=RunGeneratedScript(y/n)?
    if "%runIt%"=="y"  Call GetIGL_Generated.cmd
Cheers JW !

Both work well.

... haven't seen you for a long time :-)

k.
these scripts should be put in the wiki, or at least stickied.
I used the script from Post #3 and while it works, I want to know how it works.

Does it go through all the files and brute force changes them all? Does it have intelligence and only attempts to rename those that need it? The reason I'm asking is because I want to use this to do a batch rename during the night. If it just brute force changes all the names then when the db gets big, it can take a while. If it's selective then it should run rather quickly.

Also, I've noticed that this script or IGL has a slight rename issue where if it's date based then it'll add an extra "." like showname.2014-04-02..mp4. I've attached a jpg to illustrate. It's not a problem for NPVR but funny looking when you look at the files.
jam_zhou Wrote:The reason I'm asking is because I want to use this to do a batch rename during the night.
Apologies if I am missing the point ... I have imagegraplite in my postprocessing.bat and it renames the recording file when the recording ends.
A couple of reasons.

1. conflicts with comskip - there are workarounds, but I don't feel comfortable with them
2. I'm not sure what would happen if I'm watching a show and it suddenly gets renamed.

Number 2 is my main concern.
jam_zhou Wrote:I want to know how it works.
The line in the script

Quote:SET SQL=SELECT '%IGLite% --nfo --zap2it --oid ', oid ^
FROM Scheduled_Recording WHERE status=2 AND filename NOT LIKE '%.S%';

is saying create a line containing the text igl.exe (or whatever you have set iglite as) --nfo blah and the value in the oid column of the scheduled-recording table for each row in the scheduled recording table where its a recording (status = 2) and the file name is not in format (not like) anything .S anything. The script creates a script file containing one line for each recording that matches the "where" and then runs the script file. You can change the "where" clause based on
http://www.w3schools.com/sql/sql_like.asp
http://www.w3schools.com/sql/sql_wildcards.asp

Do you have files called sqlscript.scr and GetIGL_Generated.cmd left over when the script runs? These are created by the script as it goes along.
Good Luck.
Graham,

thanks for explaining that. So, it tries to discriminate, but in my screen capture above, it'll try to rename it again (though to the same name).

The way I'm going I'm thinking of using postprocessing.bat to create a list like GetIGL_Generated.cmd which the script creates.

I'll run this new .bat file to rename then run my video transcoding.

This will mitigate and hopefully eliminate and race or conflict conditions all this post processing can cause.

My worry is that something will happen and corrupt my database...which is why I'll be making a backup of the database before any renames.
Pages: 1 2