@echo off
setlocal enabledelayedexpansion

title by shiroka.top
rem 转载请注明出处

rem 判断是否通过拖拽操作传递了参数（文件夹路径）
if not "%~1"=="" (
    set "FOLDERPATH=%~1"
    set "FOLDERNAME=%~nx1"
    rem 判断文件夹名称是否以"DISABLED "开头
    if /i "!FOLDERNAME:~0,9!"=="DISABLED " (
        rem 如果是，移除"DISABLED "前缀
        set "NEWNAME=!FOLDERNAME:~9!"
        ren "!FOLDERPATH!" "!NEWNAME!"
    ) else (
        rem 如果不是，添加"DISABLED "前缀
        set "NEWNAME=DISABLED !FOLDERNAME!"
        ren "!FOLDERPATH!" "!NEWNAME!"
    )
    goto :eof
)

rem 如果没有参数传递（双击打开），展示菜单
:menu
echo 请输入您要执行的操作的数字：
echo 1. 为当前目录下所有文件夹添加"DISABLED "前缀。
echo 2. 移除当前目录下所有文件夹的"DISABLED "前缀。
echo 如只需要对单个mod进行操作，请将文件直接拖入bat中
echo.

set /p "CHOICE=请输入（1或2）: "
if "%CHOICE%"=="1" goto :add_disabled
if "%CHOICE%"=="2" goto :remove_disabled
echo 选择无效，请重试。
goto :menu

:add_disabled
rem 为当前目录下的所有文件夹添加"DISABLED "前缀
for /d %%D in (*) do (
    set "DIRNAME=%%D"
    if /i not "!DIRNAME:~0,9!"=="DISABLED " (
        ren "%%D" "DISABLED %%D"
    )
)
goto :eof

:remove_disabled
rem 移除当前目录下所有文件夹的"DISABLED "前缀
for /d %%D in (*) do (
    set "DIRNAME=%%D"
    if /i "!DIRNAME:~0,9!"=="DISABLED " (
        set "NEWNAME=!DIRNAME:~9!"
        ren "%%D" "!NEWNAME!"
    )
)
goto :eof