These docs are for MetaTana 2.0, coming soon
CLI
MetaTana has a Pro command-line tool for scans, folders, scraping, renaming, exports, Trakt, backups, and running MetaTana without a window. This page lists every command and what each one does.
metatana owner and metatana backup, which work without an account so you can recover an install that can't sign in or start.
How the CLI runs
The CLI works directly on your local MetaTana database. It does not go through the web app or the local API, so it does not need an API key. It is a separate process with its own database connection, so it is safe to run while the app is open.
The metatana command ships inside the desktop app and the Docker image. metatana --version prints the app version.
Install the command
| Install | How to get metatana | Library it uses |
|---|---|---|
| macOS app | Settings › Maintenance › Advanced. Command-line tool for you › Install links ~/.local/bin/metatana. Command-line tool for all users › Install links /usr/local/bin/metatana after an administrator password prompt. Remove undoes either. The link points at MetaTana.app/Contents/Resources/bin/metatana. | The app's own library |
| Windows app | The installer ships <install folder>\bin\metatana.cmd and offers Add metatana command to PATH (your user's PATH). Open a new Command Prompt or PowerShell window afterwards. Uninstalling removes the PATH entry. | The app's own library |
| Linux .deb or .rpm | Installed for you: /usr/bin/metatana links to /opt/MetaTana/resources/bin/metatana, and /usr/bin/MetaTana opens the app. | The app's own library |
| Linux AppImage | Settings › Maintenance › Advanced › Command-line tool for you › Install writes ~/.local/bin/metatana, a small script that runs the command inside the AppImage file. | The app's own library |
| Docker | Already in the image at /usr/local/bin/metatana. Run docker exec <container> metatana …. As root it switches to the container's PUID:PGID, so files it writes stay usable by the server. | The server's library in /app/data (METATANA_DATA_DIR, METATANA_DB_PATH) |
If your terminal can't find metatana after installing it for your user, add ~/.local/bin to your PATH. Settings never replaces a metatana file it did not create; it reports Another file named metatana is already there instead. On an AppImage install made with the Linux install script, ~/.local/bin/metatana is the script's app launcher, so remove it first, install the command from Settings, then run the install script again. The script keeps the command-line tool and makes MetaTana and the app menu entry open the app.
On macOS and on Linux .deb, .rpm, and .tar.gz installs, metatana with no arguments opens the app. MetaTana always opens the app.
On Windows, metatana prints its output in Command Prompt and PowerShell like any other command. The output may start with one blank line; scripts that read it should skip leading blank lines.
On Linux, metatana also runs as root and with no display, for example over SSH. The AppImage command that Settings writes does the same. If Settings shows Repair next to the command-line tool, click it to write the command again.
Pro sign-in
For the Pro check, the CLI uses the hosted session from METATANA_HOSTED_SESSION_TOKEN when it is set. Otherwise the desktop command reuses the session of the signed-in desktop app. In Docker, and on Linux over SSH without a display, the desktop session can't be read, so set METATANA_HOSTED_SESSION_TOKEN for the Pro check. On Linux without a display the command uses the default desktop data folder (~/.config/metatana/data, or under $XDG_CONFIG_HOME when it is set).
The command uses the same library as the app it came with (see the table above). Set METATANA_DB_PATH or METATANA_DATA_DIR to point it at another one (see Reference: environment variables).
Run metatana --help for the command list, or metatana for one command's flags.
Scan and undo
CLI
metatana scan <path>
Scan a folder and identify media files
metatana scan /media/incoming # identify and record matches only
metatana scan /media/incoming --ai # allow AI Vision for hard files
metatana scan /media/incoming --move --output /media/library # also move identified files
scan walks the folder, identifies each media file, and records the matches as a scan job. It prints each file with its match, confidence, and whether it needs review.
Without --move, no files are moved. --move requires --output; only files that don't need review are moved, into an organized folder layout under that folder. AI Vision is off unless you pass --ai. --dry-run is deprecated: scans don't move files unless you ask, and --dry-run with --move moves nothing.
scan also saves each file's media info, such as resolution, and picks up a poster.jpg or fanart.jpg beside each file it doesn't move, so Library shows them right away. It doesn't fetch extra metadata or artwork.
A --move run ends with the exact command that moves its files back, for example To move the files back, run: metatana undo 42.
CLI
metatana undo <job-id>
Move a scan job's files back
metatana undo 42
Moves files that scan --move relocated back to their original paths. It checks that each file and its original folder are still reachable before moving it.
Folders
CLI
metatana sources
Add, list, or remove watched folders
metatana sources add /media/movies --type movie # movie, tv, or anime
metatana sources list
metatana sources remove 3
These are the folders on the Folders page. add checks that the folder is readable before saving it. list prints each folder's ID, which the --source option of other commands takes.
Library tools
CLI
metatana health
Print a library health report
metatana health
Prints a score out of 1000, item counts for movies, TV, and anime, and a count of files per issue type.
CLI
metatana mediainfo
Print stream details for library files
metatana mediainfo # files with no resolution recorded yet
metatana mediainfo --all # every library file
metatana mediainfo --save # also store the results
Reads each file and prints its resolution, video codec, and audio and subtitle track counts. Without --save, nothing is stored. --save stores the results in the library the same way Reload media info does on a title's page. Items that need review in MetaTana are printed but not saved.
CLI
metatana scrape
Scrape metadata into the library
metatana scrape # every library item
metatana scrape --new # unscraped items only
metatana scrape --source 3 # one folder (IDs from: metatana sources list)
scrape saves metadata to your library. Each item goes through the same identify and apply steps as bulk Scrape in Library. Confident matches are applied. Uncertain ones wait in the Inbox for you to review. Locked fields are kept.
It changes library metadata only. It does not download artwork, write NFO files, fetch subtitles or trailers, or rename files. --all is the default. At the end it prints how many items were updated, need review, or failed.
CLI
metatana rename
Rename library files with your saved patterns
metatana rename --dry-run # print the plan, change nothing
metatana rename # rename files
metatana rename --source 3 # one folder
rename uses the patterns and options saved in Settings › Files › Naming for movies, TV, and anime. With --dry-run it prints each old and new path and changes nothing. Without --dry-run it renames the files, moving NFO, artwork, and subtitle files with them. Files that already have the right name are skipped, and files it can't rename safely are listed and left alone.
Each run is one batch in Activity (Show › Renames), and you can undo the batch from there. Run --dry-run first.
CLI
metatana nfo-rewrite
Rewrite NFO files from library metadata
metatana nfo-rewrite --dry-run # print which NFO files would change
metatana nfo-rewrite # rewrite NFO files
metatana nfo-rewrite --source 3 # one folder
metatana nfo-rewrite --format plex # kodi, emby, jellyfin, plex, or mediaportal2
nfo-rewrite works like Write NFO in the app. It uses the format in Settings › Files › NFO files unless you pass --format, keeps existing NFO content, and includes your metadata edits. --dry-run lists each NFO file as write, unchanged, or unavailable and changes nothing. If any selected item needs review in MetaTana, the run stops and lists those items; review them in the app, or use --source to leave them out. Each run is one entry in Activity in the app, where you can undo it.
CLI
metatana subtitles
Fetch subtitles for library items
metatana subtitles # English subtitles for every item
metatana subtitles --lang en,fr # several languages
metatana subtitles --missing-only # only items with no subtitles yet
metatana subtitles --source 3 --overwrite
subtitles uses the same download queue as Fetch subtitles in the app. Like every CLI command it needs Pro, and it also needs an OpenSubtitles or SubDL API key in Settings › Providers › Subtitles (or the matching environment variable); without a key it stops and says so. --lang defaults to en. --overwrite replaces subtitle files that already exist. Items that need review in MetaTana stop the run, as with nfo-rewrite. A download that fails for a temporary reason stays queued, and the MetaTana app tries it again later. At the end it prints how many were downloaded, queued for retry, or failed.
Trailers
CLI
metatana trailers
Fetch trailers for library items
metatana trailers
metatana trailers --missing-only
For items with a TMDb ID, finds a trailer through TMDb and saves it beside the file as . Requires yt-dlp on your PATH. Items without a TMDb ID are skipped.
Export
CLI
metatana export
Export the library with a built-in format or a saved template
metatana export --format csv # CSV to stdout
metatana export --format json --output library.json # also: xml, html, excel
metatana export --format html --output library.html # default file: metatana-library.html
metatana export --template "Markdown list" --output library.md # a saved export template
metatana export --template ./my-layout.txt # or a template file
metatana export --format csv --type movie --search "alien"
metatana export --format csv --filters "genre:contains:Horror|genre:contains:Family,year:gte:2000"
metatana export --format csv --fields title,year,genres,releaseDate,tmdbRating
Pass exactly one of --format (csv, json, xml, html, or excel) or --template. --template takes the name of a template saved in Export templates… (the ⋯ menu on the Export row in Settings › Maintenance › Backups), or a path to a template file; the file's extension decides how values are escaped. --type limits the export to movie, tv, or anime, --search to items matching the search text, and --filters to a filter expression where , means all must match and | means any one may match. --fields picks columns for built-in formats. The older snake_case names such as content_rating and file_path still work. Unknown names are skipped with a warning. CSV column headers are the field names (title, releaseDate), not display labels.
export writes an inventory file. It does not write NFO files. See Back up your library for backups.
Trakt
CLI
metatana trakt
Sign in to Trakt and sync watched state
metatana trakt auth # device-code sign-in
metatana trakt status # sign-in and credential status
metatana trakt sync # push and pull watched state
These use the same Trakt sign-in as the Sync page in the app. sync prints how many items matched, were pushed, and were pulled. See Add Trakt.
Install owner
CLI
metatana owner
Show or reset which account this install is linked to
metatana owner status # is an account linked?
metatana owner claim-code # show the claim code
metatana owner reset # unlink it
docker exec <container> metatana owner reset # Docker
The first MetaTana account that signs in to an install becomes its owner, and other accounts see This MetaTana is linked to a different account. reset unlinks the owner so the next account to sign in is linked instead. Nothing else changes: the library, settings, and API key stay as they are.
An install with no owner has a one-time claim code. Docker and NAS installs print it to the server log every time they start, until an account is linked. claim-code prints it again, and reset prints a new one. Someone signing in from another device enters it on the Enter the claim code screen. The desktop app needs no code. When an account is already linked, claim-code prints no code and tells you to run reset first.
These commands skip the Pro check on purpose. They are how you recover an install after deleting or losing the linked account. They work only on the machine that runs MetaTana, against its database; nobody can run them over the network. See One Account Per Install.
Backups
CLI
metatana backup
List, check, or restore database backups without starting MetaTana
metatana backup list # backups, newest first
metatana backup list --json
metatana backup check # can this MetaTana open the library?
metatana backup restore <backup-id> --confirm # restore on the next start
metatana backup unlock --confirm-stopped # clear records left by a stopped container
These are the same database backups as Settings › Maintenance › Backups. They work when MetaTana can't start, and they skip the Pro check.
Stop every MetaTana app or container that uses the same data folder before you restore. restore takes a name from backup list and needs --confirm. The backup replaces the library the next time MetaTana starts, and MetaTana saves a copy of the current database first. If that copy fails, the restore is refused.
check reads the library without changing it. If a newer MetaTana has already upgraded it, check names that version and the backup from before the update that this version can open. Other commands refuse such a library with exit code 65 and the same message.
unlock is for a container that was killed hard and left records another container can't check. Run it only after every app, container, and other computer that shares the data folder has stopped. It leaves the database and backup files alone.
Runtime
CLI
metatana serve
Start the web app without a desktop window
metatana serve # http://localhost:3000, listening on 0.0.0.0
metatana serve --port 8080 --host 127.0.0.1
metatana serve --runtime-role web # web only; run background-services separately
CLI
metatana background-services
Run background work without the web server
metatana background-services # start in the background
metatana background-services --foreground # run in this terminal
metatana background-services --status
metatana background-services --stop
CLI
metatana runtime-status
Show which runtime parts are running
metatana runtime-status
metatana runtime-status --json
metatana runtime-status --role web --require-running # exits non-zero if not running
Not in the CLI
Library browsing, metadata edits, field locks, media server sync, taking a new backup, Activity history, and resets are not CLI commands. Use the app, or the API for scripted access. The MCP bridge is also separate from the CLI; see API reference: MCP bridge.
Going deeper
- Reference: API: the HTTP API for scripted access
- Reference: environment variables: database path and other settings
- AI and agents: MCP bridge setup