[GH-ISSUE #15742] Windows BAT script for installing/deleting GGUF models (CLI wrapper utility) #72095

Open
opened 2026-05-05 03:28:16 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @FSSocrates on GitHub (Apr 22, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15742

This is a simple Windows batch utility that wraps Ollama CLI commands for managing GGUF-based models.

@echo off
setlocal enabledelayedexpansion

:: Use filename as model name
set "MODEL_NAME=%~n0"
set "MODEL_FILE=%MODEL_NAME%.gguf"
set "TEMP_MODELF=Modelfile_%MODEL_NAME%"

:MENU
cls
echo ============================================
echo   Ollama Manager - Model: %MODEL_NAME%
echo ============================================
echo  1. Install/Update model
echo  2. Delete model
echo  3. Exit
echo ============================================
set /p "choice=Choose option (1-3): "

if "%choice%"=="1" goto INSTALL
if "%choice%"=="2" goto DELETE
if "%choice%"=="3" goto :EOF
goto MENU

:INSTALL
echo.
echo [1/3] Checking for %MODEL_FILE%...

if not exist "%MODEL_FILE%" (
    echo ERROR: "%MODEL_FILE%" not found in this folder.
    pause
    goto MENU
)

if exist "%TEMP_MODELF%" del "%TEMP_MODELF%" >nul 2>&1

echo [2/3] Creating Modelfile...
(
    echo FROM "./%MODEL_FILE%"
    echo # Optional: TEMPLATE / PARAMETER lines
) > "%TEMP_MODELF%"

echo [3/3] Installing into Ollama...
ollama create "%MODEL_NAME%" -f "%TEMP_MODELF%"
set RESULT=%errorlevel%

del "%TEMP_MODELF%" >nul 2>&1

if not "%RESULT%"=="0" (
    echo.
    echo ERROR: Failed to create model. Ensure Ollama is running.
) else (
    echo.
    echo SUCCESS: Model "%MODEL_NAME%" is ready!
)

pause
goto MENU

:DELETE
echo.
echo Checking for existing model...

ollama list | findstr /i "%MODEL_NAME%" >nul
if errorlevel 1 (
    echo Model "%MODEL_NAME%" is not currently installed.
    pause
    goto MENU
)

echo.
echo WARNING: This will permanently delete "%MODEL_NAME%".
set /p "confirm=Are you sure? (Y/N): "

if /i not "%confirm%"=="Y" (
    echo Deletion cancelled.
    pause
    goto MENU
)

echo Deleting...
ollama rm %MODEL_NAME%

if errorlevel 1 (
    echo ERROR: Failed to remove model.
) else (
    echo Model "%MODEL_NAME%" removed successfully.
)

pause
goto MENU

Purpose:

  • Install a local GGUF model into Ollama using a double-click BAT file
  • Delete installed models safely with confirmation
  • Avoid manual CLI usage for basic model management on Windows

How it works:

  • Uses filename as model name (example: model.bat + model.gguf)
  • Creates temporary Modelfile internally
  • Runs: ollama create / ollama rm
  • Provides install/delete menu interface

Limitations:

  • Requires Ollama installed and available in PATH
  • Assumes .gguf filename matches model name
  • Does not integrate with Ollama UI or API
  • Pure CLI wrapper (Windows BAT only)

This is shared as a lightweight utility for Windows users who manage local GGUF models manually.

If not appropriate for the main repo, feel free to close or redirect to a more suitable place.

Originally created by @FSSocrates on GitHub (Apr 22, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15742 This is a simple Windows batch utility that wraps Ollama CLI commands for managing GGUF-based models. ```bat @echo off setlocal enabledelayedexpansion :: Use filename as model name set "MODEL_NAME=%~n0" set "MODEL_FILE=%MODEL_NAME%.gguf" set "TEMP_MODELF=Modelfile_%MODEL_NAME%" :MENU cls echo ============================================ echo Ollama Manager - Model: %MODEL_NAME% echo ============================================ echo 1. Install/Update model echo 2. Delete model echo 3. Exit echo ============================================ set /p "choice=Choose option (1-3): " if "%choice%"=="1" goto INSTALL if "%choice%"=="2" goto DELETE if "%choice%"=="3" goto :EOF goto MENU :INSTALL echo. echo [1/3] Checking for %MODEL_FILE%... if not exist "%MODEL_FILE%" ( echo ERROR: "%MODEL_FILE%" not found in this folder. pause goto MENU ) if exist "%TEMP_MODELF%" del "%TEMP_MODELF%" >nul 2>&1 echo [2/3] Creating Modelfile... ( echo FROM "./%MODEL_FILE%" echo # Optional: TEMPLATE / PARAMETER lines ) > "%TEMP_MODELF%" echo [3/3] Installing into Ollama... ollama create "%MODEL_NAME%" -f "%TEMP_MODELF%" set RESULT=%errorlevel% del "%TEMP_MODELF%" >nul 2>&1 if not "%RESULT%"=="0" ( echo. echo ERROR: Failed to create model. Ensure Ollama is running. ) else ( echo. echo SUCCESS: Model "%MODEL_NAME%" is ready! ) pause goto MENU :DELETE echo. echo Checking for existing model... ollama list | findstr /i "%MODEL_NAME%" >nul if errorlevel 1 ( echo Model "%MODEL_NAME%" is not currently installed. pause goto MENU ) echo. echo WARNING: This will permanently delete "%MODEL_NAME%". set /p "confirm=Are you sure? (Y/N): " if /i not "%confirm%"=="Y" ( echo Deletion cancelled. pause goto MENU ) echo Deleting... ollama rm %MODEL_NAME% if errorlevel 1 ( echo ERROR: Failed to remove model. ) else ( echo Model "%MODEL_NAME%" removed successfully. ) pause goto MENU ``` ### Purpose: - Install a local GGUF model into Ollama using a double-click BAT file - Delete installed models safely with confirmation - Avoid manual CLI usage for basic model management on Windows ### How it works: - Uses filename as model name (example: model.bat + model.gguf) - Creates temporary Modelfile internally - Runs: ollama create / ollama rm - Provides install/delete menu interface ### Limitations: - Requires Ollama installed and available in PATH - Assumes .gguf filename matches model name - Does not integrate with Ollama UI or API - Pure CLI wrapper (Windows BAT only) This is shared as a lightweight utility for Windows users who manage local GGUF models manually. If not appropriate for the main repo, feel free to close or redirect to a more suitable place.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#72095