Skip to content

Latest commit

 

History

History
185 lines (140 loc) · 5.07 KB

File metadata and controls

185 lines (140 loc) · 5.07 KB

Info Command

The info command displays detailed metadata about a ZIM archive file, showing information about its contents, structure, and technical details.

Purpose

The info command provides comprehensive inspection of ZIM files:

  • Displays metadata fields (title, creator, publisher, date, description, language, tags)
  • Shows article count and namespace distribution
  • Lists file size and ZIM format version
  • Supports both library and direct file access

Usage

zim info <file.zim or name>

The command accepts either:

  1. Library name: Display name, index number, or partial filename from zim library
  2. Direct path: Path to a .zim file outside the library

Examples

Using Library Names

# By index number
$ zim info 1
ZIM File Information
====================
File: ~/.cache/zim/wikipedia_en_comics_nopic_2024-10.zim
Article Count: 123456

Main Page: Main Page

Metadata:
  Title: Wikipedia: Comics
  Creator: Kiwix
  Publisher: Wikimedia Foundation
  Date: 2024-10-15
  Description: Wikipedia articles about comics
  Language: en
  Tags: comics,wikipedia

Namespaces:
  A: Articles (120000 entries)
  I: Images (3456 entries)
  J: Text images (789 entries)

File Size: 5.2 GB
ZIM Version: 7.0

Using Direct File Path

# Direct file path
$ zim info ~/Downloads/wikipedia_en_physics.zim
ZIM File Information
====================
File: ./archives/wikipedia_en_physics.zim
Article Count: 98765

Metadata:
  Title: Wikipedia: Physics
  Creator: Kiwix
  Publisher: Wikimedia Foundation
  Date: 2024-09-20
  Description: Physics-related Wikipedia articles
  Language: en
  Tags: physics,wikipedia

Namespaces:
  A: Articles (95000 entries)
  I: Images (3765 entries)

File Size: 3.1 GB
ZIM Version: 7.0

Output Format

The command displays information in several sections:

Basic Information

  • File: Path to the ZIM file
  • Article Count: Total number of articles in the file
  • Main Page: Main entry point article (if defined)
  • UUID: Unique identifier for the ZIM file (hexadecimal)

Metadata Section

  • Title: Descriptive title of the ZIM file
  • Creator: Tool/entity that created the ZIM file
  • Publisher: Organization that published the content
  • Date: Publication date
  • Description: Detailed description of contents
  • Language: Primary language code (ISO 639-1)
  • Tags: Comma-separated tags for categorization

Namespaces Section

Shows distribution of content across ZIM namespace types:

Namespace Description Typical Content
A Articles Main article content
B Article metadata Metadata for articles
I Images Image files (PNG, JPG, SVG)
M ZIM metadata ZIM file metadata
U Categories Category listings
V Video Video content
W Well known entries Standard entries
X Search indexes Search index data

Technical Details

  • File Size: Human-readable file size (GB, MB, etc.)
  • ZIM Version: Format version (major.minor)

File Resolution Methods

Library Mode

When given a library reference, the command resolves it through the library system:

# Index number from 'zim library'
$ zim info 1

# Display name from 'zim library'
$ zim info comics

# Partial filename match
$ zim info wikipedia_en_comics

Direct Path Mode

When given a file path, it accesses the file directly:

# Absolute path
$ zim info /path/to/file.zim

# Relative path
$ zim info ../files/archive.zim

# Home directory shortcut
$ zim info ~/archives/zimfile.zim

Article Count vs. Namespace Counts

Important distinction:

  • Article Count: Total articles in the ZIM file (from ZIM metadata)
  • Namespace Counts: Entries in each specific namespace type

Some ZIM files contain significant non-article content (images, metadata, indexes), so the total namespace entries may exceed the article count.

Error Handling

The command will fail with appropriate error messages for:

  • File not found: When the specified file doesn't exist
  • Invalid ZIM file: When the file is not a valid ZIM archive
  • Empty library: When referencing a library name but no matching files exist

Implementation Details

The info command:

  1. Resolves the file path using internal.ResolveZIMPathWithInteraction()
  2. Opens the ZIM file using internal.OpenZIM()
  3. Extracts metadata using ZIM library methods (z.Title(), z.Creator(), etc.)
  4. Counts namespace entries using z.EntriesWithNamespace()
  5. Formats output with clear section headers

Related Commands

Command Description How it Relates
library List library files Provides names/indexes for info command
list List articles Shows detailed contents after viewing metadata
read Read articles Accesses content after verifying file info

See Also