DirMeta: Directory Metadata Scanner & Viewer
DirMeta is a command-line utility designed to scan filesystem directory structures, capture detailed metadata about files and folders, and provide both machine-readable (JSON) output saved to a file and a human-readable tree view loaded from that file. It's a general-purpose tool useful for documenting, understanding, or analyzing directory layouts.
Features
- Recursive Scan: Scans directories deeply to capture all nested files, folders, and symbolic links.
- Rich Metadata: Collects essential information:
- Relative Path
- Type (file, folder, symlink)
- Permissions (standard string format)
- Size (for files)
- Timestamps (Modification, Access, Metadata Change, and Creation/Birth if available)
- File Extension (for files)
- Symlink Target (for symlinks)
- Direct JSON File Output: The scanner (
structure-scan) writes the collected metadata directly to a specified or automatically named JSON file. - Tree Viewer: The viewer (
structure-view) loads a scan's JSON file and displays the structure as a formatted tree in the terminal, including key metadata for quick analysis. - CLI Tools: Installs two easy-to-use commands:
structure-scanandstructure-view. - Configurable: Options to include/exclude hidden files (
.prefix) and specify the output file path. - Pure Python: Runs on Python >= 3.7 without requiring any external libraries.
- Cross-Platform: Tested on Linux, macOS, and Windows.
Installation
It is strongly recommended to install dirmeta within a Python virtual environment to avoid conflicts with system packages.
1. Using pip
pip install dirmeta
2. Installing from Source (e.g., after cloning the repository)
# Clone the repository (if needed)
# git clone <repository_url>
# cd dirmeta
# Create and activate a virtual environment (Python 3)
python3 -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
# Install the package
pip install .
Usage
1. Scan a Directory (structure-scan)
The structure-scan command scans the specified directory path and writes the collected metadata as a JSON object to a file.
Command:
structure-scan [OPTIONS] ROOT_DIR
Arguments:
ROOT_DIR: The path to the directory you want to scan.
Options:
-i,--include-hidden: Include hidden files and directories (names starting with '.') in the scan. By default, they are excluded.-o FILE,--output FILE: Specify the path for the output JSON file. If omitted, defaults to<ROOT_DIR_NAME>.jsonsaved in the directory containingROOT_DIR. For example, scanning/path/to/mydatawould default to saving/path/to/mydata.json. Scanning.would default to saving<CURRENT_DIR_NAME>.jsonin the parent directory.-v,--verbose: Enable debug logging (prints progress/warnings tostderr).
Examples:
# Scan the current directory (excluding hidden files).
# Output saved to '<CURRENT_DIR_NAME>.json' in the parent directory.
structure-scan .
# Scan '/var/log', including hidden files, save to 'log_scan.json' in the current directory
structure-scan --include-hidden --output log_scan.json /var/log
# Scan '~/my_project' verbosely.
# Output saved to '~/my_project.json' (assuming default output location).
structure-scan -v ~/my_project
# Scan 'data_folder' and save output inside it
structure-scan --output data_folder/scan_metadata.json data_folder
2. View Scan Results (structure-view)
The structure-view command reads a JSON file previously generated by structure-scan and displays the directory structure as a formatted tree in your terminal.
Command:
structure-view [OPTIONS] JSON_FILE
Arguments:
JSON_FILE: The path to the JSON file created bystructure-scan.
Options:
-v,--verbose: Enable debug logging for the viewer (rarely needed).
Examples:
# View the scan results stored in 'project_scan.json'
structure-view project_scan.json
# View the log scan results
structure-view log_scan.json
Example Output (structure-view scan.json)
Scan Root: /path/to/your/directory
Scan Timestamp: 2023-10-30T12:00:00Z
Schema Version: 1.0
------------------------------------------------------------
├── .gitattributes [F] -rw-r--r-- 60 B (Mod: ...)
├── LICENSE [F] -rw-r--r-- 1.1 KB (Cre: ... | Mod: ...)
# ... rest of tree structure ...
Output JSON Schema (structure-scan output file)
The scanner produces a JSON object (written to the output file) with the following top-level keys:
scanner_version: Version string of the schema (e.g., "1.0" based on the provided script).scanned_path: The absolute, resolved path of the directory that was scanned.timestamp_utc: ISO 8601 timestamp (UTC, withZsuffix) indicating when the scan finished.items: An array of objects, each representing a scanned file, folder, or symlink found withinscanned_path.
Each object inside the items array contains the following fields:
path(String): Path relative toscanned_path, using/separators. The root directory itself is represented as..type(String): The type of the filesystem item:"file","folder", or"symlink".permissions(String): Standard file mode string (e.g.,"drwxr-xr-x","-rw-r--r--").modified_utc(String | Null): ISO 8601 timestamp (UTC) of last modification, ornullif unavailable.accessed_utc(String | Null): ISO 8601 timestamp (UTC) of last access, ornullif unavailable.metadata_changed_utc(String | Null): ISO 8601 timestamp (UTC) of last metadata change (Unixctime), ornullif unavailable.created_utc(String | Null, Optional): ISO 8601 timestamp (UTC) of file creation/birth, if available on the platform/filesystem. Field may be absent if not found.size_bytes(Integer, Optional): Size in bytes. Only present fortype: "file".file_extension(String | Null, Optional): Lowercase file extension without the leading dot (e.g.,"txt","pdf").nullif the file has no extension. Only present fortype: "file".symlink_target(String | Null, Optional): The target path the symlink points to (can be relative or absolute).nullif reading the target failed. Only present fortype: "symlink".
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for dirmeta 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dirmeta-0.1.tar.gz | 12.0 kB | Without provenance | Details for dirmeta-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dirmeta-0.1-py3-none-any.whl | Python 3 | none | any | Details for dirmeta-0.1-py3-none-any.whl |
Total release size: 22.5 kB
Release files / dirmeta-0.1.tar.gz
| Download URL | dirmeta-0.1.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee124df3a6c4cccffd5183399c25e223e3e689188cc72749658b67631132cace
|
|
BLAKE2b-256 checksum How to use checksums |
cd6dbe4d978181346f8251c9e5a12e7246c819864966b8046d19c9400585dece
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.8
|
Release files / dirmeta-0.1-py3-none-any.whl
| Download URL | dirmeta-0.1-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
faf948346588ba002d91b27f37022465357da9c42906ada3dbc5f64d633d3a02
|
|
BLAKE2b-256 checksum How to use checksums |
6e4b52d9477233c6c080039c7b6bc6c53a72c7fba3ab306d4124a5fe2efc06be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.8
|
Security for dirmeta 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.