2020-05-01, 10:17 AM
Hey Guys,
I've been running PostProcessing.bat for years on V4 and never had an issue - at least after I got it doing what I wanted
However, On 5.0.3 and 5.0.4 it seems to only work when it feels like it. I have the batch file rename the .ts file to get rid of the date/Time suffix. and when it works it's perfect, but at the moments it only happens about 30% of the time.
It's to do with the %REC_TITLE% output.
Can you take a look and see if you can work out why it doesn't work all the time. If it works more than once, that should mean that there is nothing wrong with the coding of the file shouldn't it?
Anyway, I await your responses.
Contents of my bat file: Note, the Bold line is where it fails all the time, except for when it doesn't. If it gets past that it finishes ok. The lines in italics append HD or SD to the file for subsequent processing for commercial removal. The extra HD/SD tacked on after the.ts is to prevent the batch file looping and adding numerous _HD or _SD one after the other - they are removed on induction into the commercial removal setup. It works 100% for that part.
@Echo on
GoTo :BEGIN
:BEGIN
SETLOCAL
Set SCRIPTNAME=%0
Set BASEDIR=c:\Users\Public\NPVR-data
Set LOGFILE=%BASEDIR%\Logs\RecordingSucceeded.log
Set ERRORLOG=%BASEDIR%\Logs\ERRORLOG.log
Set FILENAME=%1
Set CH_NUM=%2
Set OID=%3
Set DEV_OID=%4
Set REC_TITLE=%5
Set RecDir=C:\Users\Public\Videos\
Call :LOGMSG Recording complete - filename: %FILENAME% ChannelNUM: %CH_NUM% OID: %OID% DeviceOID: %DEV_OID% Title: %REC_TITLE%
cd /D %RecDir%
forfiles /S /M *.ts /C "cmd /c ren *.ts %REC_TITLE%.ts"
If ERRORLEVEL 1 call :Error Error Renamimg File: %FILENAME% Title: %REC_TITLE%
timeout 300
If %CH_NUM%==5 GoTo :RENAMEHD
If %CH_NUM%==7 GoTo :RENAMEHD
If %CH_NUM%==13 GoTo :RENAMEHD
If %CH_NUM%==14 GoTo :RENAMEHD
If %CH_NUM%==27 GoTo :RENAMEHD
If %CH_NUM%==29 GoTo :RENAMEHD
If %CH_NUM%==35 GoTo :RENAMEHD
If %CH_NUM%==46 GoTo :RENAMEHD
GoTo :RENAMESD
--------------------------------------------------------------
:RENAMEHD
forfiles /S /M *.ts /C "cmd /c ren *.ts %REC_TITLE%_HD.ts.HD"
Call :LOGMSG HD Renamimg complete - filename: %FILENAME% - ChNum: %CH_NUM% - Title: %REC_TITLE%
GoTo :EXITJOB
--------------------------------------------------------------
:RENAMESD
forfiles /S /M *.ts /C "cmd /c ren *.ts %REC_TITLE%_SD.mpg.SD"
Call :LOGMSG SD Renamimg complete - filename: %FILENAME% - ChNum: %CH_NUM% - Title: %REC_TITLE%
GoTo :EXITJOB
--------------------------------------------------------------
:LOGMSG
echo %*
echo %date:~4% %time% [%SCRIPTNAME%] %* >> %LOGFILE%
Goto :EOF
--------------------------------------------------------------
:EXITJOB
Exit /b
--------------------------------------------------------------
:Error
echo %*
echo %date:~4% %time% [%SCRIPTNAME%] %* >> %ERRORLOG%
Goto :EOF
I've been running PostProcessing.bat for years on V4 and never had an issue - at least after I got it doing what I wanted
However, On 5.0.3 and 5.0.4 it seems to only work when it feels like it. I have the batch file rename the .ts file to get rid of the date/Time suffix. and when it works it's perfect, but at the moments it only happens about 30% of the time.
It's to do with the %REC_TITLE% output.
Can you take a look and see if you can work out why it doesn't work all the time. If it works more than once, that should mean that there is nothing wrong with the coding of the file shouldn't it?
Anyway, I await your responses.
Contents of my bat file: Note, the Bold line is where it fails all the time, except for when it doesn't. If it gets past that it finishes ok. The lines in italics append HD or SD to the file for subsequent processing for commercial removal. The extra HD/SD tacked on after the.ts is to prevent the batch file looping and adding numerous _HD or _SD one after the other - they are removed on induction into the commercial removal setup. It works 100% for that part.
@Echo on
GoTo :BEGIN
:BEGIN
SETLOCAL
Set SCRIPTNAME=%0
Set BASEDIR=c:\Users\Public\NPVR-data
Set LOGFILE=%BASEDIR%\Logs\RecordingSucceeded.log
Set ERRORLOG=%BASEDIR%\Logs\ERRORLOG.log
Set FILENAME=%1
Set CH_NUM=%2
Set OID=%3
Set DEV_OID=%4
Set REC_TITLE=%5
Set RecDir=C:\Users\Public\Videos\
Call :LOGMSG Recording complete - filename: %FILENAME% ChannelNUM: %CH_NUM% OID: %OID% DeviceOID: %DEV_OID% Title: %REC_TITLE%
cd /D %RecDir%
forfiles /S /M *.ts /C "cmd /c ren *.ts %REC_TITLE%.ts"
If ERRORLEVEL 1 call :Error Error Renamimg File: %FILENAME% Title: %REC_TITLE%
timeout 300
If %CH_NUM%==5 GoTo :RENAMEHD
If %CH_NUM%==7 GoTo :RENAMEHD
If %CH_NUM%==13 GoTo :RENAMEHD
If %CH_NUM%==14 GoTo :RENAMEHD
If %CH_NUM%==27 GoTo :RENAMEHD
If %CH_NUM%==29 GoTo :RENAMEHD
If %CH_NUM%==35 GoTo :RENAMEHD
If %CH_NUM%==46 GoTo :RENAMEHD
GoTo :RENAMESD
--------------------------------------------------------------
:RENAMEHD
forfiles /S /M *.ts /C "cmd /c ren *.ts %REC_TITLE%_HD.ts.HD"
Call :LOGMSG HD Renamimg complete - filename: %FILENAME% - ChNum: %CH_NUM% - Title: %REC_TITLE%
GoTo :EXITJOB
--------------------------------------------------------------
:RENAMESD
forfiles /S /M *.ts /C "cmd /c ren *.ts %REC_TITLE%_SD.mpg.SD"
Call :LOGMSG SD Renamimg complete - filename: %FILENAME% - ChNum: %CH_NUM% - Title: %REC_TITLE%
GoTo :EXITJOB
--------------------------------------------------------------
:LOGMSG
echo %*
echo %date:~4% %time% [%SCRIPTNAME%] %* >> %LOGFILE%
Goto :EOF
--------------------------------------------------------------
:EXITJOB
Exit /b
--------------------------------------------------------------
:Error
echo %*
echo %date:~4% %time% [%SCRIPTNAME%] %* >> %ERRORLOG%
Goto :EOF