dreamer2908

IBM with pause and dummy commands

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