Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 54

Thread: Yet Another RenameRecordings Batch files

  1. #11
    Join Date
    Oct 2005
    Posts
    216
    Quote Originally Posted by johnsonx42 View Post
    perhaps if you post your postprocessing.bat we could see where things are going wrong?
    @echo off


    REM make sure the file passed actually exists
    if not exist "%~f1" goto error


    set DBPath=C:\Users\Public\NPVR\npvr.db3
    set NSHelper="C:\Program Files (x86)\NPVR\NScriptHelper.exe"
    set subtitle=
    set title=

    echo Getting recording title
    FOR /F "tokens=*" %%i in ('%NSHelper% -title "%~f1"') do SET title=%%i


    echo Getting recording subtitle
    FOR /F "tokens=*" %%i in ('%NSHelper% -subtitle "%~f1"') do SET subtitle=%%i


    REM Make sure the variables aren't empty
    if "%title%" == "" goto error
    if "%subtitle%" == "" goto nosubtitle


    Echo removing illegal characters from the variables
    echo original: %title%
    set title=%title:?=-%
    echo %title%
    set title=%title:/=-%
    echo %title%
    set title=%title:\=-%
    echo %title%
    set title=%title::=-%
    echo %title%


    echo original: %subtitle%
    set subtitle=%subtitle:?=-%
    echo %subtitle%
    set subtitle=%subtitle:/=-%
    echo %subtitle%
    set subtitle=%subtitle:\=-%
    echo %subtitle%
    set subtitle=%subtitle::=-%
    echo %subtitle%


    REM Create new filename
    SET newfile="%~dp1%title% - %subtitle%%~x1"

    echo New filename is: %newfile%


    echo Checking that the new filename is not the same as the old
    if "%~f1" == %newfile% goto error


    REM Check if file exists and change filename if it does
    set Qnum=1
    :CheckFile
    if not exist %newfile% goto renamefile
    if %Qnum%==10 goto error
    set /a Qnum=%Qnum%+1
    SET newfile="%~dp1%title% - %subtitle% (%Qnum%)%~x1"
    echo checking %newfile%
    goto checkfile


    :nosubtitle
    Echo There was a title, but no subtitle
    SET newfile="%~f1"


    Echo replacing underscores so I know this has been processed
    set newfile=%newfile:_= - %


    :renamefile
    echo Checking that the new filename is not the same as the old
    if "%~f1" == %newfile% goto error


    echo renaming the file to %newfile%
    move /y "%~f1" %newfile%


    echo checking the rename worked and updating the database if so
    if exist %newfile% %NSHelper% -rename "%~f1" %newfile%


    goto end


    :error
    Echo Error! Check above...


    :end
    echo Finished.

    EDIT: I put in a "pause" right before the ":end" to see what was happening, and got a command pop-up window with the message "Error! Check above...". So it seems to be running, but something is wrong.
    Last edited by JimF; 2011-07-17 at 10:39 PM. Reason: Add error message

  2. #12
    Join Date
    Oct 2005
    Posts
    216
    EDIT 2:From looking at the error messages when I insert Pause at various places, it appears that the second SET statement should be: set NSHelper=C:\Program Files (x86)\NPVR\NScriptHelper.exe (without the quotation marks). But that still doesn't get the renaming to work properly. Perhaps this is a difference between a 64-bit OS and a 32-bit OS?
    HDHomeRun Prime, Win7 64-bit, NPVR 3.2.9

  3. #13
    Join Date
    Nov 2007
    Location
    United Kingdom
    Posts
    51
    Quote Originally Posted by JimF View Post
    EDIT 2:From looking at the error messages when I insert Pause at various places, it appears that the second SET statement should be: set NSHelper=C:\Program Files (x86)\NPVR\NScriptHelper.exe (without the quotation marks). But that still doesn't get the renaming to work properly. Perhaps this is a difference between a 64-bit OS and a 32-bit OS?
    type REM in front of the first line and you will be able to see all of the code that is running.
    Also, try this:-
    Press and hold the start button, then press the R button
    type cmd & press enter
    type in the "c:\path to your batch file\renamerecording.bat" "c:\path to your video\video.ts"
    See what happens. You can copy & paste from the command-prompt into here. Also, make sure you use the speech marks.

  4. #14
    Join Date
    Oct 2005
    Posts
    216
    This is what I get:

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\Jim>"C:\Users\Public\NPVR\Scripts\renamer ecording.bat" "F:\Sid the Scie
    nce Kid\Sid the Science Kid_20110719_11001130.ts"

    C:\Users\Jim>REM @echo off

    C:\Users\Jim>REM make sure the file passed actually exists

    C:\Users\Jim>if not exist "F:\Sid the Science Kid\Sid the Science Kid_20110719_1
    1001130.ts" goto error

    C:\Users\Jim>set DBPath=C:\Users\Public\NPVR\npvr.db3

    C:\Users\Jim>set NSHelper=C:\Program Files (x86)\NPVR\NScriptHelper.exe

    C:\Users\Jim>set subtitle=

    C:\Users\Jim>set title=

    C:\Users\Jim>echo Getting recording title
    Getting recording title
    \NPVR\NScriptHelper.exe was unexpected at this time.

    C:\Users\Jim>FOR /F "tokens=*" %i in ('C:\Program Files (x86)\NPVR\NScriptHelper
    .exe -title "F:\Sid the Science Kid\Sid the Science Kid_20110719_11001130.ts"')
    do SET title=%i

    C:\Users\Jim>
    Last edited by JimF; 2011-07-19 at 03:51 PM.
    HDHomeRun Prime, Win7 64-bit, NPVR 3.2.9

  5. #15
    Join Date
    Nov 2007
    Location
    United Kingdom
    Posts
    51
    Quote Originally Posted by JimF View Post
    This is what I get:

    C:\Users\Jim>set NSHelper=C:\Program Files (x86)\NPVR\NScriptHelper.exe

    C:\Users\Jim>set subtitle=

    C:\Users\Jim>set title=

    C:\Users\Jim>echo Getting recording title
    Getting recording title
    \NPVR\NScriptHelper.exe was unexpected at this time.

    C:\Users\Jim>FOR /F "tokens=*" %i in ('C:\Program Files (x86)\NPVR\NScriptHelper
    .exe -title "F:\Sid the Science Kid\Sid the Science Kid_20110719_11001130.ts"')
    do SET title=%i
    Change set NSHelper=C:\Program Files (x86)\NPVR\NScriptHelper.exe in your batch file to the line below with the speech-marks in it (I did say don't forget the speechmarks!
    Code:
    set NSHelper="C:\Program Files (x86)\NPVR\NScriptHelper.exe"

  6. #16
    Join Date
    Oct 2005
    Posts
    216
    OK, here is what I get.

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\Jim>"C:\Users\Public\NPVR\Scripts\RenameR ecording.bat" "F:\Sid the Scie
    nce Kid\Sid the Science Kid_20110719_11001130.ts"

    C:\Users\Jim>REM @echo off

    C:\Users\Jim>REM make sure the file passed actually exists

    C:\Users\Jim>if not exist "F:\Sid the Science Kid\Sid the Science Kid_20110719_1
    1001130.ts" goto error

    C:\Users\Jim>set DBPath=C:\Users\Public\NPVR\npvr.db3

    C:\Users\Jim>set NSHelper="C:\Program Files (x86)\NPVR\NScriptHelper.exe"

    C:\Users\Jim>set subtitle=

    C:\Users\Jim>set title=

    C:\Users\Jim>echo Getting recording title
    Getting recording title

    C:\Users\Jim>FOR /F "tokens=*" %i in ('"C:\Program Files (x86)\NPVR\NScriptHelpe
    r.exe" -title "F:\Sid the Science Kid\Sid the Science Kid_20110719_11001130.ts"'
    ) do SET title=%i
    'C:\Program' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\Jim>echo Getting recording subtitle
    Getting recording subtitle

    C:\Users\Jim>FOR /F "tokens=*" %i in ('"C:\Program Files (x86)\NPVR\NScriptHelpe
    r.exe" -subtitle "F:\Sid the Science Kid\Sid the Science Kid_20110719_11001130.t
    s"') do SET subtitle=%i
    'C:\Program' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\Jim>REM Make sure the variables aren't empty

    C:\Users\Jim>if "" == "" goto error

    C:\Users\Jim>Echo Error! Check above...
    Error! Check above...

    C:\Users\Jim>echo Finished.
    Finished.

    C:\Users\Jim>
    HDHomeRun Prime, Win7 64-bit, NPVR 3.2.9

  7. #17
    Join Date
    Nov 2007
    Location
    United Kingdom
    Posts
    51
    Okay then, run these two commands in the command prompt and post what you get:-

    C:\Progra~1\NPVR\NScriptHelper.exe -title "F:\Sid the Science Kid\Sid the Science Kid_20110719_11001130.ts"

    C:\Progra~2\NPVR\NScriptHelper.exe -title "F:\Sid the Science Kid\Sid the Science Kid_20110719_11001130.ts"

    Hopefully one will work and try that one as the NSHelper (without quotes). I don't think it will work with paths with spaces in so you have to use the ~. I looked at mine and remembered I had the same issues.

  8. #18
    Join Date
    Oct 2005
    Posts
    216
    Here they are. The first didn't work, and the second crashed NScriptHelper entirely (there was a pop up that it had stopped working).

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\Jim>C:\Progra~1\NPVR\NScriptHelper.exe -title "F:\Sid the Science Kid\S
    id the Science Kid_20110719_11001130.ts"
    The system cannot find the path specified.

    C:\Users\Jim>C:\Progra~2\NPVR\NScriptHelper.exe -title "F:\Sid the Science Kid\S
    id the Science Kid_20110719_11001130.ts"

    Unhandled Exception: System.TypeInitializationException: The type initializer fo
    r 'NUtility.DatabaseHelper' threw an exception. ---> System.BadImageFormatExcept
    ion: Could not load file or assembly 'System.Data.SQLite, Version=1.0.65.0, Cult
    ure=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. An att
    empt was made to load a program with an incorrect format.
    File name: 'System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToke
    n=db937bc2d44ff139'
    at NUtility.DatabaseHelper..ctor()
    at NUtility.DatabaseHelper..cctor()

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\M
    icrosoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure lo
    gging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
    ion!EnableLog].

    --- End of inner exception stack trace ---
    at NUtility.DatabaseHelper.GetInstance()
    at NUtility.ScheduledRecording.Load(String clause, Boolean descending)
    at NScriptHelper.Program.Main(String[] args)

    C:\Users\Jim>

    ================================================== ===
    Also, I tried changing to the root (C:\) directory before running these, and got slightly different results:

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Windows\system32>cd\

    C:\>C:\Progra~1\NPVR\NScriptHelper.exe -title "F:\Sid the Science Kid\Sid the Sc
    ience Kid_20110719_11001130.ts"
    The system cannot find the path specified.

    C:\>C:\Progra~2\NPVR\NScriptHelper.exe -title "F:\Sid the Science Kid\Sid the Sc
    ience Kid_20110719_11001130.ts"
    Access is denied.

    C:\>

    In the second case, the pop-up said that NScriptHelper was not a valid Win32 application.

    So maybe we have a 64-bit OS problem, but I don't know how to fix it. By the way, I tried changing directories once to the NPVR program directory and then invoking the SET command on NScriptHelper; it didn't work, but I could do that if you want to see what happens.
    HDHomeRun Prime, Win7 64-bit, NPVR 3.2.9

  9. #19
    Join Date
    Nov 2003
    Location
    NextPVR HQ, Wellington, New Zealand
    Posts
    76,001
    See if this version helps.

  10. #20
    Join Date
    Nov 2007
    Location
    United Kingdom
    Posts
    51
    The set command in your batch file needs to be:-
    Code:
    set NSHelper=C:\Progra~2\NPVR\NScriptHelper.exe
    I'm running windows xp 32 bit on my NPVR machine so I'm not sure how much help I can be trying to sort out your issues with it not working under Windows 7 64 bit. Maybe Sub can chip in if the stuff below doesn't work...

    Follow this guide to edit your path variable in windows. Add the line below to the END of it:-
    Code:
    ;C:\Progra~2\NPVR;C:\Users\Public\NPVR
    Save it and restart your computer.

    Then follow this guide to open the command-prompt. Copy & paste this command in and see what happens (it should be on one line):-
    Code:
    C:\Progra~2\NPVR\NScriptHelper.exe -title "F:\Sid the Science Kid\Sid the Science Kid_20110719_11001130.ts"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •