NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Information Community Announcements v
« Previous 1 … 3 4 5 6 7 56 Next »
Yet Another RenameRecordings Batch files

 
  • 0 Vote(s) - 0 Average
Yet Another RenameRecordings Batch files
JimF
Offline

Member

Posts: 217
Threads: 19
Joined: Oct 2005
#11
2011-07-17, 06:49 PM (This post was last modified: 2011-07-17, 10:39 PM by JimF.)
johnsonx42 Wrote: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.
JimF
Offline

Member

Posts: 217
Threads: 19
Joined: Oct 2005
#12
2011-07-18, 09:21 PM
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.4.8
SANGER_A2
Offline

Member

Posts: 51
Threads: 8
Joined: Nov 2007
#13
2011-07-19, 09:03 AM
JimF Wrote: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.
JimF
Offline

Member

Posts: 217
Threads: 19
Joined: Oct 2005
#14
2011-07-19, 03:37 PM (This post was last modified: 2011-07-19, 03:51 PM by JimF.)
This is what I get:

Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Users\Jim>"C:\Users\Public\NPVR\Scripts\renamerecording.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>
HDHomeRun Prime, Win7 64-bit, NPVR 3.4.8
SANGER_A2
Offline

Member

Posts: 51
Threads: 8
Joined: Nov 2007
#15
2011-07-19, 04:12 PM
JimF Wrote: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! Smile
Code:
set NSHelper="C:\Program Files (x86)\NPVR\NScriptHelper.exe"
JimF
Offline

Member

Posts: 217
Threads: 19
Joined: Oct 2005
#16
2011-07-19, 05:12 PM
OK, here is what I get.

Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Users\Jim>"C:\Users\Public\NPVR\Scripts\RenameRecording.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.4.8
SANGER_A2
Offline

Member

Posts: 51
Threads: 8
Joined: Nov 2007
#17
2011-07-19, 06:57 PM
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.
JimF
Offline

Member

Posts: 217
Threads: 19
Joined: Oct 2005
#18
2011-07-19, 07:14 PM
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 © 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 © 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.4.8
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,627
Threads: 767
Joined: Nov 2003
#19
2011-07-19, 07:22 PM
See if this version helps.
SANGER_A2
Offline

Member

Posts: 51
Threads: 8
Joined: Nov 2007
#20
2011-07-19, 07:41 PM
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"
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (6): « Previous 1 2 3 4 5 6 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  Generate NextPVR import XML from recorded TV .wtv files from WMC Jimixter 5 5,265 2021-05-06, 03:34 PM
Last Post: a1blues
  Generate missing thumbnails for video files imported into NextPVR Jimixter 0 2,574 2019-12-16, 07:28 PM
Last Post: Jimixter
  Files plugin tmrt 13 7,299 2014-01-09, 11:16 PM
Last Post: mvallevand
  Manual RenameRecording Batch File SANGER_A2 0 2,175 2011-10-08, 11:11 AM
Last Post: SANGER_A2
  NPVR Rename Recordings Batch File raceviper13 8 7,959 2011-04-23, 11:52 PM
Last Post: raceviper13
  Search DB batch util pBS 4 2,480 2009-09-03, 10:01 AM
Last Post: pBS
  Updated BDA scan files MixMan 1 2,180 2009-08-12, 08:19 PM
Last Post: martint123
  PostProcessing Dvr-MS files to remove comercial breaks crlorentzen 0 1,546 2008-09-13, 08:38 PM
Last Post: crlorentzen
  Batch to surely Hibernate & Update EPG dfdario 1 1,731 2008-03-09, 02:32 PM
Last Post: cakes
  NEW PLUG-IN: Files McBainUK 13 4,034 2007-06-05, 06:47 PM
Last Post: cybershaman

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode