dreamer2908

IBM with pause and 1 sec delay

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