My Agent

Okay, so I've been watching this Agentic AI business for a while now (my newsletters can't stop going on about it), and frankly, not too interested; the idea of letting some AI loose on my own workflows is not currently appealing.

But then a perennial thought of mine came to mind again today, a job I've been putting off for well, years because it would take ALL DAY, and is actually not that important, though it would be nice.

This sounds like exactly the sort of thing I could trust an AI agent to do, I figured. The job?

Sort my movie collection.


It's got a sorta sort going on, there are folders like "Action" and "Horror", but not much more. I started a folder of "Directors", which is a great way to categorise movies, but then you need to make shortcuts back into the genre folder and what you really want is to have ALL the movies inside there, and then create shortcuts to the movies in all sorts of other folders like "Genre" (inside there being Action, Horror, Comedy, etc., and maybe inside there, Dark Comedy, Mime, Slapstick, whatever!), "Actors", "Year", and so on.

Media managers aren't my bag. Nor are expensive "frontier" subscriptions.

TLDR: The bugger just did it in three minutes. Locally. On Windows.

I don't know if writing about it while my mind is still blown is such a good idea (there will be many tuts like this I reckon; there can never be enough), but here goes;

How I organised my entire movie collection just the way I've always wanted it, in three minutes, excluding setup time, on Windows..

Oh wait a minute, what setup? I hear you say. Well, actually not a lot.

You only need three things, and you might already have most of them;

Hold it, before that (oh wait, this is sounding like stone soup) you will need a build environment. Install the latest Python and Git, then install Microsoft Visual Studio 2022 (NOT ANY OTHER YEAR!3). These are all click-and-go installers these days; now you can build and run all that "AI stuff". Three things..

1. Something to run your AI model, provide an API for interacting with the model, etc. (llama.cpp is what I'm using, compiles in a couple of commands, loads of cute apps use this as their backend, but I prefer to interact directly).

2. An AI model (I'm using QWEN 3.6, which is available on huggingface and gagging to get into a harness)

3. A harness, which as the name suggest, cradles your AI model, keeping it safe-ish and possibly warm. The model runs inside the harness, which keeps it in check, stops it falling off the rails and makes the whole looping-learning-doing thing happen. I'm using OpenCode. This is what enables your AI model to interact with the outside world, and with real things, like your files.

Yes, I realise OpenCode is supposed to be setup with a "project" and you are supposed to do it in some coding project's folder, but like I said, I couldn't care less about that stuff; I just want my movies organised.

The steps:


* In a shell:

cd C:\Path\to\your\AI-stuff
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp

You are now inside llama.cpp's directory and we can set about building llama.cpp itself..

This is all one line, though it will be split up here on the web. Here we are just setting an environmental variable to enable CUDA compilation, or else your AI will run VERY slowly.:

"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -B build -DGGML_CUDA=ON

My MS build tools directory wasn't in the PATH, so I'm assuming yours isn't either, hence full paths; change if required; then run:

"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build build --config Release -j


* Go do something else until its done.


Once it's finished compiling, we can test llama.cpp is working:

C:\path\to\bin\Release\llama-cli.exe -m "C:\path\to\your\model.gguf" -p "Tell me a joke" -ngl 999 -n 32

If all goes to plan you should see a lame joke. This will make you laugh, not because the joke is funny, but because you have just unlocked local AI chat. No API fees, no monthly subscriptions; pick a model and go2.

There are a few cute desktop apps for this local LLM malarkey, but llama.cpp is probably all you need. It has a CLI and web interface right off the bat, so you can go chat, Chat-GPT-Style, right away:

http://127.0.0.1:8080


You will want to use better parameters for running your actual model, and maybe a script to enable you to choose your model on-the-fly (pick a model and go, what I just said).

Gemini came up with this which works great (save as a .bat file somewhere):

@echo off
setlocal enabledelayedexpansion

:: ----------------------------------------------------
:: Configuration Pathways
:: ----------------------------------------------------
set "SERVER_EXE=I:\AI\llama.cpp\build\bin\Release\llama-server.exe"
set "MODEL_DIR=I:\AI\models\LLavacheckpoints"

:: Verify directory exists
if not exist "%MODEL_DIR%" (
    echo [ERROR] Model directory not found: %MODEL_DIR%
    pause
    exit /b
)

:MENU
cls
echo ====================================================
echo               Available GGUF Models
echo ====================================================
echo.

:: Loop through directory and index GGUF files
set "count=0"
for %%F in ("%MODEL_DIR%\*.gguf") do (
    set /a count+=1
    set "model[!count!]=%%~nxF"
    set "model_path[!count!]=%%~fF"
    echo  [!count!] %%~nxF
)

if %count%==0 (
    echo [ERROR] No .gguf models found in %MODEL_DIR%
    pause
    exit /b
)

echo.
echo ====================================================
echo.

:: Prompt User for Choice
set "choice="
set /p "choice=Select a model number to launch (1-%count%): "

:: Validate Input
if not defined choice goto MENU
if %choice% lss 1 goto MENU
if %choice% gtr %count% goto MENU

:: Resolve selection variables
set "SELECTED_MODEL_NAME=!model[%choice%]!"
set "SELECTED_MODEL_PATH=!model_path[%choice%]!"

cls
echo ====================================================
echo  Launching llama-server
echo  Model: %SELECTED_MODEL_NAME%
echo ====================================================
echo.


"%SERVER_EXE%" -m "%SELECTED_MODEL_PATH%" --host 127.0.0.1 --port 8080 -ngl 999 -c 65536 -np 1 --keep 12000 --timeout 600 --fit off --cache-type-k q8_0 --cache-type-v q8_0

:: pause
exit


You will want to edit in your own paths and whatever hardware constraints (this is for an RTX3060/12GB4). Pass --help to llama-server.exe to see all the available options.

This is great and all, but to fully unlock the capabilities of the latest "Agentic" models, you are going to want to put that model in a harness..


Enter OpenCode.

This is simple to install (using Node.js):

npm install -g opencode-ai

This assumes you have Python installed. Now head here:

C:\Users\<YOU>\.config\opencode

And open opencode.jsonc in a text editor. Paste in something like this:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "llamacpp/qwen3.6",
  "provider": {
    "llamacpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Llama.cpp (Local)",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1"
      },
      "models": {
        "qwen3.6": {
          "name": "Qwen 3.6"
        }
      }
    }
  }
}

You could also specify multiple models, which can be chosen with the -m flag or by using /models inside OpenCode..


{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "llamacpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Llama.cpp (Local)",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1"
      },
      "models": {
        "qwen3.6": { "name": "Qwen 3.6" },
        "llama3": { "name": "Llama 3" },
        "mistral": { "name": "Mistral" }
      }
    }
  }
}

But this is purely academic, as llama.cpp won't care what OpenCode thinks the model is, the tokens will all be the same, as far as I can gather. But unless you specify something, you won't be able to launch OpenCode. Second run, that's different, it will fallback to its previous config. But first run... *rolls eyes*

Okay, now you can launch OpenCode, and it can communicate with your AI model. All that's left is to get it to DO something. This is where the magic happens..

I had no clue how to go about prompting an AI agent, but another AI got me up-to-speed pretty quickly and suggested this:

Write and execute a Python script to organize this movie directory based on the following specific structural and metadata rules:

1. Scan the current directory and group loose files by their shared base name (for example, "A Night to Remember.1958.BR"). All matching auxiliary files (such as .srt, .hash, .nfo) must be kept and processed together with the main video file (.mkv, .mp4, .avi). Treat existing dedicated movie folders as single items.

2. Query an unofficial IMDb API or scrape data using the shared base name to retrieve the Director, Cast (Actors), Release Date, Writers, and Genres for each film.

3. Move Phase: Move the grouped items into a structured folder hierarchy: "\Directors\Director Name\". 
   - For loose files sharing a base name, move all of them directly into the target director's folder as loose files. Do not wrap them in a separate subfolder.
   - For existing movie folders, move the entire folder inside the director's folder.

4. Shortcut Phase: Create virtual taxonomies by generating root folders for "\Actors", "\Dates", "\Writers", and "\Genres".

5. Inside those virtual taxonomy folders, use Windows PowerShell COM scripting via the "WScript.Shell" object to programmatically create native Windows Shortcuts (.lnk) pointing directly back to the movie's new physical location under the "\Directors" path. 

6. Handle multi-value attributes (like multiple actors or genres) by creating a separate shortcut in every corresponding category folder.

I saved that to a file inside my test directory (oh yeah, test first) named Sort Movies.ai. Then I open a shell in that directory and simply do:

opencode --prompt "Read the rules in @Sort Movies.ai and generate and execute the Python script now."

This, I have to say, was an amazing experience1.

Watching an AI "think" through your task is fun. And watching it hit a wall (no matches in OMDB as file name contains encoding info) and reason as to the issue and its solution, is quite remarkable; it hits walls and figures out solutions on-the-fly is; informative as well as entertaining.

But the kicker, for me, was once it had finished, in under three minutes, it's actually done a remarkable job in the test folder (yeah, I'm not stupid!), with only a couple of stray files (which it has seen and plans to fix) and, weirdly, duplicates of all shortcuts (which again, it has seen and plans to fix, though I could also do that in a few seconds myself, if required; a minor issue). I chose the "fix" option and a few seconds later the folder is pretty much exactly how I would expect it to look after me spending a half hour on the task..

Actors\Kevin Bacon and Actors\Jack Nicholson both contain shortcuts to Directors\Rob Reiner\A Few Good Men 1992.1080p.BluRay.x265.AAC.mp4, as does Writers\Aaron Sorkin, as does Genres\Drama, as does, well, others too. YES! This is what I wanted! THANK YOU!

All in all, a job I've been putting off for years because it would take all day, can be done in minutes, with the right tools. The "real" folder is considerably larger, but I'm feeling pretty confident about smacking this bitch up and walking away, doing something else while my unpaid assistant does grunt work for no more than some green electricity (did I hear "B00Yah!"?).

Curiously, my later attempts to refine this script.ai, to catch the things it fixed perfectly well on its second pass (you know, with a mind to the larger, invariably more varied data set), created convoluted sessions that burned tokens like crazy (at a whopping, $0.00/token, no less) and did not produce the desired result, unless I did a wee bit back-and-forth afterwards. Yes! You can keep working with your agent to refine the results and get the job, in the end, done.

This tells me a) I have a lot to learn, and as with recent image models, it's probably best let AI write these prompts in future and b) people must waste a shit-ton of money5.

;o)


references:
1. I later learned that I was fortunate, very fortunate, in that quite quickly, I got exactly the result I was looking for.

2. I've written quote a few wee useful things with my local models in recent months and more and more they are becoming capable of getting real stuff done, as well as telling lame jokes.

3. If you really really tried and still find get this version of the Visual Studio Build Tools, even after you logged into your MS dev account, mail me. I'll send you my copy, as I have fibre and M$ can suck my cock.

4. I'll say it again, the RTX 3060 12GB is hands-down the best value graphics card you can buy if you plan to fuck around with AI. I'd need a whole blog to explain all the reasons why! But hey, I just sorted MY FUCKING MOVIE COLLECTION in three minutes using local compute, which is 100% wind/wave power, baby!

5. Seriously, your $200/mo subscription is costing them $8000/mo as it is, so whatever pay-as-you-go income they can grab is most welcome, as they all have multi-billion dollar deficits.

 ©  2026 « autoconfig.corz.org » 26.7.1