Advertisement
Guest User

merge.bat

a guest
Sep 16th, 2022
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. @echo off
  2.  
  3. if not defined PYTHON (set PYTHON=python)
  4. if not defined VENV_DIR (set VENV_DIR=venv)
  5.  
  6. mkdir tmp 2>NUL
  7.  
  8. %PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
  9. if %ERRORLEVEL% == 0 goto :start_venv
  10. echo Couldn't launch python
  11. goto :show_stdout_stderr
  12.  
  13. :start_venv
  14. if [%VENV_DIR%] == [-] goto :skip_venv
  15.  
  16. dir %VENV_DIR%\Scripts\Python.exe >tmp/stdout.txt 2>tmp/stderr.txt
  17. if %ERRORLEVEL% == 0 goto :activate_venv
  18.  
  19. for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
  20. echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
  21. %PYTHON_FULLNAME% -m venv %VENV_DIR% >tmp/stdout.txt 2>tmp/stderr.txt
  22. if %ERRORLEVEL% == 0 goto :activate_venv
  23. echo Unable to create venv in directory %VENV_DIR%
  24. goto :show_stdout_stderr
  25.  
  26. :activate_venv
  27. set PYTHON="%~dp0%VENV_DIR%\Scripts\Python.exe"
  28. echo venv %PYTHON%
  29.  
  30. :ask1
  31. set /p filename1="Enter the name of the first file: "
  32. if not exist %filename1% (
  33. echo "File does not exist"
  34. goto :ask1
  35. )
  36. if exist %filename1% echo "Ok, using %filename1%"
  37.  
  38. :ask2
  39. set /p filename2="Enter the name of the second file: "
  40. if not exist %filename2% (
  41. echo "File does not exist"
  42. goto :ask2
  43. )
  44. if %filename2% == %filename1% (
  45. echo "Files must be different"
  46. goto :ask2
  47. )
  48. if exist %filename2% echo "Ok, using %filename2%"
  49.  
  50. :ask_alpha
  51. set "alpha=0.5"
  52. echo "Enter alpha value (0.0-1.0)."
  53. set /p alpha="Or press [ENTER] for default [%alpha%]: "
  54.  
  55. :ask_filename
  56. set "output=merged"
  57. echo "Enter output filename without file extension."
  58. set /p output="Or press [ENTER] for default [%output%]: "
  59.  
  60. :launch
  61. %PYTHON% merge.py %filename1% %filename2% --alpha %alpha% --output %output%
  62. pause
  63. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement