Guest User

Untitled

a guest
May 2nd, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1.  
  2.  
  3. @echo off
  4. setlocal
  5.  
  6. REN *.mkv old.mkv
  7.  
  8. rem Roses are red, violets are blue, sugar is sweet, and so are you.
  9. rem Enjoy your usual ratio: 5% of lines do the actual work, and the rest are there to make sure they work. (It's like 1%, actually)
  10.  
  11. for /f "tokens=2 delims=:." %%x in ('chcp') do set cp=%%x
  12. chcp 65001>nul
  13. set sourcefile=old.mkv
  14. set targetfile=[Ecchihiro]_Netoge_no_Yome_wa_Onnanoko_ja_Nai_to_Omotta?_-_01v2_[720p_Hi10P_AAC][56298581].mkv
  15. set app=xdelta3.exe
  16. set changes=changes.vcdiff
  17. set sourcefiletmp=sourcefile.tmp
  18. set targetfiletmp=targetfile.tmp
  19. set movesourcefile=1
  20. set movetargetfile=1
  21. set olddir=old
  22. set WORKINGDIR=%CD%
  23. chdir /d "%~dp0"
  24. (call )
  25.  
  26. call :find_xdelta3 && call :find_inputs "%~1" && call :run_patch
  27. call :gtfo
  28. goto :eof
  29.  
  30.  
  31. :find_xdelta3
  32. (call)
  33. if exist "%app%" (
  34. (call )
  35. ) else (
  36. echo The required application "%app%" can't be found!
  37. )
  38. goto :eof
  39.  
  40. :find_inputs
  41. (call)
  42. if exist "%~1" (
  43. set "sourcefile=%~f1"
  44. set "targetfile=%~dp1%targetfile%"
  45. set "sourcefiletmp=%~dp1%sourcefiletmp%"
  46. set "targetfiletmp=%~dp1%targetfiletmp%"
  47. set "olddir=%~dp1%olddir%"
  48. (call )
  49. )
  50. if not exist "%sourcefile%" (
  51. if exist "..\%sourcefile%" (
  52. set "sourcefile=..\%sourcefile%"
  53. set "targetfile=..\%targetfile%"
  54. set "sourcefiletmp=..\sourcefile.tmp"
  55. set "targetfiletmp=..\targetfile.tmp"
  56. set "olddir=..\%olddir%"
  57. (call )
  58. ) else (
  59. if exist "..\..\%sourcefile%" (
  60. set "sourcefile=..\..\%sourcefile%"
  61. set "targetfile=..\..\%targetfile%"
  62. set "sourcefiletmp=..\..\sourcefile.tmp"
  63. set "targetfiletmp=..\..\targetfile.tmp"
  64. set "olddir=..\..\%olddir%"
  65. (call )
  66. ) else (
  67. if exist "..\..\..\%sourcefile%" (
  68. set "sourcefile=..\..\..\%sourcefile%"
  69. set "targetfile=..\..\..\%targetfile%"
  70. set "sourcefiletmp=..\..\..\sourcefile.tmp"
  71. set "targetfiletmp=..\..\..\targetfile.tmp"
  72. set "olddir=..\..\..\%olddir%"
  73. (call )
  74. ) else (
  75. echo Error: Source file "%sourcefile%" not found.
  76. echo You must put it in the same folder as this script.
  77. (call)
  78. )
  79. )
  80. )
  81. ) else (
  82. (call )
  83. )
  84. if not exist "%changes%" (
  85. echo Error: VCDIFF file "%changes%" is missing.
  86. echo Please extract everything from the archive.
  87. (call)
  88. )
  89. goto :eof
  90.  
  91. :run_patch
  92. echo Attempting to patch "%sourcefile%"...
  93. if %movesourcefile% equ 1 (
  94. move "%sourcefile%" "%sourcefiletmp%" > nul
  95. ) else (
  96. set "sourcefiletmp=%sourcefile%"
  97. )
  98. if %movetargetfile% equ 0 set "targetfiletmp=%targetfile%"
  99. %app% -d -f -s "%sourcefiletmp%" "%changes%" "%targetfiletmp%"
  100. if %movesourcefile% equ 1 move "%sourcefiletmp%" "%sourcefile%" > nul
  101. if %movetargetfile% equ 1 move "%targetfiletmp%" "%targetfile%" > nul
  102. if exist "%targetfile%" (
  103. mkdir "%olddir%" 2>nul
  104. move "%sourcefile%" "%olddir%"
  105. echo Done.
  106. (call )
  107. goto :eof
  108. )
  109. echo Error occured! Patching wasn't successful!
  110. (call)
  111. pause
  112. goto :eof
  113.  
  114. :gtfo
  115. chdir /d "%WORKINGDIR%\old"
  116. REN old.mkv [Ecchihiro]_Netoge_no_Yome_wa_Onnanoko_ja_Nai_to_Omotta?_-_01_[720p_Hi10P_AAC][D232A51F].mkv
  117. chcp %cp%>nul
  118. (call )
  119. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment