Skip to content
On this page

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.

CLI access is Pro Every command checks for a signed-in MetaTana Pro account before it runs. On the Free plan, or when the account can't be verified, the command stops with an error. From MetaTana 2.2 it also stops when the account still has to agree to updated Terms of Service or Privacy Policy: open MetaTana, agree, then run the command again. The exceptions are 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

InstallHow to get metatanaLibrary it uses
macOS appSettings › 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 appThe 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 .rpmInstalled 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 AppImageSettings › 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
DockerAlready 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. On Docker and headless installs the command uses the session a Pro browser sign-in left for that install's background work. Set METATANA_HOSTED_SESSION_TOKEN when nobody signs in through a browser, or when the install uses its own TMDb key. 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 --help for one command's flags.

A command piped into another program that stops reading early, such as metatana scan /media/incoming 2>&1 | head, stops printing and still finishes its work.

Scan and undo

CLI metatana scan <path> Scan a folder or one file 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/Heat (1995).mkv"       # one file (MetaTana 2.2 and later)
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. Warnings and errors go to stderr; from MetaTana 2.2, set METATANA_LOG_LEVEL=info to see every provider request there too.

The one file can be any media file a scan in the app takes, including an .iso disc image or a .ts file. A folder inside a library folder, such as /media/Movies/New, scans only that folder. A folder that holds library folders but is inside none, such as /media holding your Movies and Anime folders, is refused with exit code 1 and a message that names the library folders to scan instead. One file in such a folder still scans. Scanning a library folder at the place you reconnected it to keeps the folder's type and saved paths, so no second copy of its titles appears. A library folder inside the folder you scan is left out: it is scanned on its own, with its own type.

A file the scan can't read, or one that is gone before its turn, is left out and named, for example ✗ Heat (1995).mkv: can't be read (left out). The rest of the folder is scanned (and moved, with --move), and a file it couldn't read makes the run exit 1.

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. Files get the names Organize gives them: the parts of a film split into parts keep - cd1 and - cd2, a file with several episodes keeps its range (S01E01-E02), a film keeps its edition, and an episode goes under its show's title. An episode with no season number stays where it is, with Not moved: no season number. From MetaTana 2.2, each file's NFO, artwork, subtitles and extras (trailers, bonus clips) move with it, renamed to match, as Organize moves them. Extras count as identified, not as needing review, since they never wait in the Inbox. Disc folders are not moved. 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, so Library shows them right away. From MetaTana 2.2 it links the extras it finds (a show's Extras clips, a film's trailers) to their show or film, as a scan in the app does. It doesn't fetch extra metadata or artwork.

A --move run that moved at least one file ends with the exact command that moves its files back, for example To move the files back, run: metatana undo 42. A file that could not be moved stays where it was, marked ✗ Move failed; the summary says how many could not be moved and the run exits 1. A move removes the folders it emptied, up to the folder you scanned.

From MetaTana 2.2, Ctrl+C stops scan after the file it is on. The titles it saved stay in your Library, and Activity lists the run as "Stopped scanning" with that folder.

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 moves back only the files that run moved, to where that scan found them, even after a later scan of the moved files. From MetaTana 2.2, the NFO, artwork, subtitles and extras that went with a file come back with it, under their old names. It checks that each file and its original folder are still reachable before moving it. If any file or sidecar could not go back, for example because a new file now has its old name, undo names it, prints how many files were undone, and exits 1. It also removes the folders it emptied in the output folder; the output folder itself stays.

Folders

CLI metatana sources Add, list, or remove watched folders
metatana sources add /media/movies --type movie       # movie, tv, anime, or mixed
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. A mixed folder holds movies and shows together and lets MetaTana work out each title's type. list prints each folder's ID and type, and the ID is what the --source option of other commands takes. remove removes a folder the way Remove folder… on the Folders page does: its scans stop, its titles leave the Library unless another folder holds them, and a running app stops watching it. Its files stay on disk.

Library tools

CLI metatana list List the library's titles
metatana list                     # every title
metatana list --type movie --json # movies, as JSON

Prints one line per title, as Library shows them: two copies of a film and a show's episodes are one title each. Titles that wait for review say so.

CLI metatana inbox Show what waits in the Inbox
metatana inbox
metatana inbox --json

Prints what waits in the Inbox (review, duplicates, renames to approve, and so on) with the counts the app shows. Decide them in the Inbox.

CLI metatana health Print a library health report
metatana health

Prints the score out of 1000 and the issues Settings › Maintenance › Library health shows, with 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. A file with no video track reads no video. Files in a library folder you reconnected are read at the folder's new place. Without --save, nothing is stored. --save stores the results in the library the same way Reload media info does on a title's page, and updates the resolution, codec and HDR counts in Library › Browse by › Stats. Items that need review in MetaTana are printed but not saved. A file it can't read makes it exit 1 after the summary.

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, and the line for each says why it waits (an NFO protects the title, the year did not match, and so on). Locked fields are kept.

It changes library metadata only. It does not download artwork, write NFO files, fetch subtitles, or rename files. --all is the default. At the end it prints how many items were updated, need review, or failed. When any item failed, for example because its folder is offline or a provider is down, it exits 1 after the summary. Items left for review don't count as 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 from MetaTana 2.2 also the files that move with it (NFO, artwork, subtitles, a film's extras), and changes nothing. Without --dry-run it renames the files, moving those files with them. Files that already have the right name are skipped, and files it can't rename safely are listed and left alone. From MetaTana 2.2 that includes anything in a show's Extras folder, an episode file whose name says it is an OVA, a special or an opening or ending clip, one whose name has two different episode numbers, an episode with no season or episode number yet (when your pattern uses them), and a file whose name another file's episode already has (check which file is that episode). These are listed as left alone, and a dry run that leaves only such files exits 0. Titles MetaTana has not identified yet (no match found, or a show name two shows share that you have not picked) are listed as "Left alone, not identified yet" and keep their names.

Each run is one batch in Activity (Show › Renames), and you can undo the batch from there. If the app starts while a run is going, Activity shows the run as running, not stalled. 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 writes each title in its folder's own NFO format, else the format in Settings › Files › NFO files, unless you pass --format. It follows Write a short outline, Single studio and Lock data from that page, keeps existing NFO content, and includes your metadata edits. --dry-run lists each NFO file as write, unchanged, or unavailable and changes nothing. An item that needs review in MetaTana is left alone and listed with why; the rest are written. Only when every selected item needs review is nothing written. Titles MetaTana has not identified yet are listed as "Left alone, not identified yet" and get no NFO. 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 API key in Settings › Providers › Subtitles (or OPENSUBTITLES_API_KEY); 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. 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.

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; any other value, such as movies, stops with exit code 1 and writes nothing. --search to items matching the search text, and --filters to a filter expression where , means all must match and | means any one may match. A field the filter does not know, such as a typo, stops the export with an error that lists the filter fields. --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. auth exits 1 when the code expires before you confirm it. sync prints how many items matched, were pushed, and were pulled, and exits 1 when it lists any errors, for example when Trakt can't be reached. 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. On Docker and NAS installs, the account that enters the new claim code becomes the owner, even while the install still holds the old owner's session for background work. 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