Advertisement
Guest User

vdr2chapter

a guest
Oct 22nd, 2013
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.70 KB | None | 0 0
  1. @echo off
  2. set TMPFILE=tmp
  3. set COMSKIP=D:\opt\DTV\comskip\comskip.exe
  4. cd /d %~dp0
  5.  
  6. :bat_start
  7. set chapter_txt_name=%~dpn1
  8. set chapter_txt_name=%chapter_txt_name:.chapters=%
  9. set chapter_txt_name=%chapter_txt_name:.d2v=%
  10. set TRIMFILE="%~dpn1.vdr"
  11.  
  12. if not exist %TRIMFILE% (
  13.   call %COMSKIP% "%~dpn1.ts"
  14. )
  15. copy %TRIMFILE% %TMPFILE%
  16.  
  17. setlocal ENABLEDELAYEDEXPANSION
  18.  
  19. set CHAPTER=c
  20.  
  21. for /F "tokens=1,2,3 delims=:" %%A in ( %TMPFILE% ) do (
  22.   set /a t_hour=%%A
  23.   set t_minute=%%B
  24.   set t_second=%%C
  25.  
  26.   if "!t_second:~-5!"=="start" (
  27.     set t_second=!t_second: start=!
  28.     set STATUS=cix
  29.    REM set /a OFFSETS=-1
  30.     set /a OFFSETS=0
  31.   ) else if "!t_second:~-3!"=="end" (
  32.     set t_second=!t_second: end=!
  33.     set STATUS=cox
  34.    REM set /a OFFSETS=1
  35.     set /a OFFSETS=0
  36.    ) else (
  37.     goto end
  38.   )
  39.  
  40.   if "!t_minute:~0,1!"=="0" (
  41.      set /a t_minute=!t_minute:~-1!
  42.   ) else (
  43.     set /a t_minute=!t_minute!
  44.   )
  45.  
  46.   set t_msec=!t_second:.=!0
  47.   if "!t_msec:~0,1!"=="0" (
  48.    set /a t_msec=!t_msec:~-4!
  49.   ) else (
  50.     set /a t_msec=!t_msec!
  51.   )
  52.  
  53.   set /a t_msecond=!t_hour!*3600000+!t_minute!*60000+!t_msec!
  54.  
  55.   if !t_msecond! EQU 0 (
  56.     set /a t_msecond=0
  57.   ) else (
  58.     set /a t_msecond=!t_msecond!+!OFFSETS!
  59.   )
  60.  
  61.   set t_msecond=!t_msecond!
  62.   set CHAPTER=!CHAPTER!-!t_msecond!!STATUS!
  63.  
  64. )
  65.  
  66. set CHAPTER=!CHAPTER!-0eox-c
  67. echo !CHAPTER!>%TMPFILE%
  68.  
  69. endlocal
  70.  
  71. if exist "%chapter_txt_name%.chapter" (
  72.   copy %TMPFILE% "%chapter_txt_name%(チャプタースキップ用).chapter"
  73. ) else (
  74.   copy %TMPFILE% "%chapter_txt_name%.chapter"
  75. )
  76. del %TMPFILE% %TRIMFILE%
  77.  
  78. rem 次のファイルがあれば :bat_start に戻る
  79. shift
  80. if not "%~1"=="" goto bat_start
  81. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement