Last active
April 15, 2024 06:12
-
-
Save JySzE/94686099207e3d260d17a6c02ed0623a to your computer and use it in GitHub Desktop.
JySzE MPV Conf updater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Version 1.2 | |
:: 04/14/2024 | |
@echo off | |
SETLOCAL EnableDelayedExpansion | |
:: Define configuration files and their corresponding GIST URLs | |
set "CONFIG_FILES[0]=mpv.conf" | |
set "GIST_URLS[0]=https://gist.githubusercontent.com/JySzE/db4149cad726b3b6955dca8d47a19721/raw" | |
set "CONFIG_FILES[1]=input.conf" | |
set "GIST_URLS[1]=https://gist.githubusercontent.com/JySzE/ced7f506629c32f44adf4fe43a341189/raw" | |
:: The directory to store and backup configuration files | |
set "CONFIG_DIR=%~dp0\mpv" | |
echo Which configuration file would you like to update? | |
echo 1. mpv.conf | |
echo 2. input.conf | |
echo 3. Both | |
echo 4. Exit | |
set /p CHOICE=Enter your choice (1-4): | |
if "!CHOICE!"=="4" goto endscript | |
:: Adjust user choice to zero-based index if not "Download all" or "Exit" | |
set /a "INDEX=!CHOICE!-1" | |
:: Iterate over each file based on choice | |
for /L %%i in (0, 1, 1) do ( | |
if "!CHOICE!"=="3" set "DOWNLOAD=1" | |
if "!INDEX!"=="%%i" set "DOWNLOAD=1" | |
if defined DOWNLOAD ( | |
set "CONFIG_FILE=!CONFIG_FILES[%%i]!" | |
set "GIST_URL=!GIST_URLS[%%i]!" | |
set "CONFIG_PATH=!CONFIG_DIR!\!CONFIG_FILE!" | |
set "BACKUP_PATH=!CONFIG_PATH!.bak" | |
echo Checking if !CONFIG_FILE! exists... | |
if exist "!CONFIG_PATH!" ( | |
echo Backing up !CONFIG_FILE!... | |
move "!CONFIG_PATH!" "!BACKUP_PATH!" | |
) | |
echo Downloading !CONFIG_FILE!... | |
curl -L !GIST_URL! -o "!CONFIG_PATH!" | |
if !ERRORLEVEL! == 0 ( | |
echo !CONFIG_FILE! updated successfully. | |
) else ( | |
echo Failed to update !CONFIG_FILE!. | |
) | |
) | |
set "DOWNLOAD=" | |
) | |
:endscript | |
ENDLOCAL | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment