A tool to map directory contents and save output as TXT or JSON.
Project description
Documentation for mapContentTool
Overview
mapContentTool is a command-line tool for mapping the structure of a directory, selecting files and folders interactively, and exporting the directory structure with selected file contents. The output can be saved as a .txt (default) or .json file. Additionally, the tool can be installed as a Python library to provide the map-content command for direct usage.
Features
- Interactive Selection:
- Navigate directory structures.
- Select or deselect files and folders interactively.
- Recursive Handling:
- Selecting a folder includes all its files and subfolders.
- Deselecting a folder removes all its files and subfolders from the selection.
- File Content Embedding:
- Embeds the content of selected files directly into the output structure.
- Output Options:
- Default:
.txtformat. - Optional:
.jsonformat with a detailed structure.
- Default:
- Exclusion Capabilities:
- Exclude specific directories (e.g.,
node_modules,.git).
- Exclude specific directories (e.g.,
- Convenient Command:
- Install as a Python library to use the
map-contentcommand directly.
- Install as a Python library to use the
- Comprehensive Logging:
- Logs all actions and errors for debugging and tracking.
- Outputs the full path of the generated file in the logs.
- Full Directory Mapping:
- Outputs the directory structure even if no files are selected.
Installation
Install mapContentTool as a Python package via pip:
pip install map-content-tool
Usage
Command-Line Options
python mapContentTool.py [directory] [options]
Or, after installation, use the standalone command:
map-content [directory] [options]
Options
| Option | Description | Default |
|---|---|---|
[directory] |
Root directory to scan. If not provided, the current directory is used. | Current directory |
-o, --output |
Specify the output file. Supports .txt (default) and .json. |
output.txt |
-e, --exclude |
Space-separated list of directories to exclude from scanning. | node_modules, .git |
Examples
Using Python Script
-
Basic Usage:
python mapContentTool.py- Scans the current directory.
- Outputs the structure to
output.txt.
-
Specify an Output File:
python mapContentTool.py -o my_directory.json
- Outputs the directory structure to
my_directory.json.
- Outputs the directory structure to
-
Exclude Specific Directories:
python mapContentTool.py -e dist build
- Excludes the
distandbuilddirectories from the scan.
- Excludes the
-
Scan a Custom Directory:
python mapContentTool.py /path/to/directory
- Scans the
/path/to/directoryand outputs the structure tooutput.txt.
- Scans the
Using the map-content Command
-
Basic Usage:
map-content
- Scans the current directory.
- Outputs the structure to
output.txt.
-
Custom Directory:
map-content /path/to/directory -
Exclude Specific Directories:
map-content -e dist build
-
Output as JSON:
map-content -o output.json
Output Format
Default .txt Format
- The
.txtformat retains the JSON-like structure for readability.
Optional .json Format
- Example:
{
"name": "root_folder",
"path": "/path/to/root_folder",
"type": "directory",
"items": [
{
"name": "subfolder1",
"path": "/path/to/root_folder/subfolder1",
"type": "directory",
"items": [
{
"name": "file1.txt",
"path": "/path/to/root_folder/subfolder1/file1.txt",
"type": "file",
"contents": "This is the content of file1.txt."
}
]
}
]
}
Interactive UI
Navigation
- Arrow keys: Move through the directory tree.
- Space: Select or deselect files and folders.
- Enter: Confirm selection and generate output.
- Q: Quit without saving.
Logs
- Logs are written to
file_selector.log. - Tracks:
- Errors
- Directory scanning progress
- File content embedding
- User interactions
- Full path of the generated file
Error Handling
- Handles missing directories and permission errors gracefully.
- If any uncaught exception occurs, it logs the error and exits with a message to check the logs.
Dependencies
- Python 3.x
- Modules:
osjsonurwidloggingsysargparsesetuptools
Changelog
Latest Updates
1.2.1
- Fixed: Directory structure is now saved even when no files are selected (previously required file selection)
Previous Versions
- Made
.txtthe default output format. - Added
.jsonas an optional output format. - Restored the functionality of showing selected files inside a folder.
- Improved folder selection and deselection logic to include all nested items.
- Updated logging and documentation.
- Enabled the use of the
map-contentstandalone command via setuptools. - Outputs the full path of the generated file in the logs.
Known Issues
- None at the moment.
For feature requests or bug reports, please contact the developer or create an issue in the repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file map_content_tool-1.2.1.tar.gz.
File metadata
- Download URL: map_content_tool-1.2.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca9185ca3a4c06556b68fde92fc812adf0664d48ff31dc65a9f1271190349717
|
|
| MD5 |
72db354aba1a4d99147a37109f59ea25
|
|
| BLAKE2b-256 |
5357f66c01a39f43803ae0fbdd4c9d04f7b832f285efbd1c13fc2695a71bbba9
|
File details
Details for the file map_content_tool-1.2.1-py3-none-any.whl.
File metadata
- Download URL: map_content_tool-1.2.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff321c64bc00d12cdbced76cc2aa9c7cb3531f952c77eaa5e5888a33134a5df0
|
|
| MD5 |
703394625aabed015af4b737bfdc4496
|
|
| BLAKE2b-256 |
2659697fae3cd87c023a22f71b9aacd0822ef80b05cbd0553c71716e1cdb8836
|