dreamer2908

IBM with pause

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