JSPM

dir-analysis-tool

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q52679F
  • License MIT

A cross-platform command-line tool that analyzes directories and outputs size, file counts, and file type classifications

Package Exports

  • dir-analysis-tool
  • dir-analysis-tool/bin/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dir-analysis-tool) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Directory- ๐Ÿ“ Depth Control: Limit scanning depth for performanceAnalyzer

A powerful cross-platform command-line tool written in TypeScript that analyzes directories and provides comprehensive insights about their contents, including file classification, large file detection, duplicate analysis, and advanced reporting features.

๐Ÿš€ Features

Core Analysis

  • ๐Ÿ“Š Directory Analysis: Get total size, file count, and folder count
  • ๐Ÿ“‚ File Classification: Automatically categorize files by type (images, videos, documents, etc.)
  • ๐Ÿ”„ Recursive Scanning: Analyze nested directories with optional recursion
  • ๐Ÿšซ Smart Exclusions: Skip common directories like node_modules, .git, etc.
  • ๏ฟฝ Depth Control: Limit scanning depth for performance

Advanced Features (Phase 1)

  • ๐Ÿ” Large File Detection: Identify files exceeding customizable size thresholds
  • ๐Ÿ”„ Duplicate File Detection: Find identical files and calculate wasted space
  • ๐Ÿ“Š Progress Indicators: Real-time progress bars during analysis
  • ๐Ÿ“‹ CSV Export: Export results, large files, and duplicates to CSV format
  • โš™๏ธ Configuration Files: Save and load analysis settings from config files
  • ๐Ÿ“ File Size Filters: Filter analysis by minimum/maximum file sizes
  • ๐Ÿ“… Date Range Filters: Filter files by modification date ranges
  • ๐ŸŒณ Tree View Output: Beautiful directory tree visualization
  • ๐Ÿ“ˆ Top N Largest Files: Show ranking of largest files
  • ๐Ÿ“ญ Empty File Detection: Identify and report empty files

Interactive Features (Phase 2)

  • ๐ŸŽฏ Interactive Mode: Dynamic CLI interface for exploration and analysis
  • ๐Ÿ‘€ Watch Mode: Real-time monitoring of directory changes
  • ๐Ÿ“Š HTML Reports: Beautiful HTML reports with interactive charts
  • ๐Ÿ”„ Directory Comparison: Compare two directories side-by-side
  • ๐ŸŽจ Rich Visualizations: Charts and graphs for better data understanding

Output & Reporting

  • ๐ŸŽจ Beautiful Terminal Output: Colorful display with emoji icons
  • ๐Ÿ“‹ Multiple Formats: Human-readable terminal output, JSON, CSV, or HTML
  • ๐Ÿ“ˆ Detailed Statistics: Comprehensive metrics and insights
  • ๐Ÿ—‚๏ธ Categorized Reports: Separate exports for different data types

Installation

Using npm/pnpm globally

npm install -g dir-analysis-tool
# or
pnpm install -g dir-analysis-tool

Using npx (no installation)

npx dir-analysis-tool [options]

Local development

git clone <repository>
cd dir-analysis-tool
pnpm install
pnpm build

Usage

Basic usage

dir-analysis-tool

Analyze a specific directory

dir-analysis-tool --path /path/to/directory

Enable large file detection (100MB threshold)

dir-analysis-tool --large-files

Custom large file threshold (50MB)

dir-analysis-tool --large-files 52428800

Enable duplicate detection

dir-analysis-tool --duplicates

Export to CSV

# Export general analysis
dir-analysis-tool --csv

# Export with custom filename
dir-analysis-tool --csv my-analysis.csv

# Export large files to CSV
dir-analysis-tool --large-files --csv-large large-files.csv

# Export duplicates to CSV
dir-analysis-tool --duplicates --csv-duplicates duplicates.csv

Use configuration file

dir-analysis-tool --config ./my-config.json

Combine multiple features

dir-analysis-tool --path /my/project --large-files --duplicates --csv --progress --max-depth 5

Get JSON output

dir-analysis-tool --json

Disable recursive scanning

dir-analysis-tool --no-recursive

Exclude specific patterns

dir-analysis-tool --exclude "*.log" "temp*" "cache"

Options

Option Description Default
-p, --path <path> Target directory to analyze . (current directory)
-r, --recursive Recursively analyze nested directories true
--no-recursive Disable recursive analysis -
-j, --json Output results in JSON format false
-t, --types Show file type classification summary true
--no-types Hide file type classification -
-e, --exclude <patterns...> Exclude file patterns or directories []
-l, --large-files [threshold] Detect large files (default: 100MB) undefined
-d, --duplicates Enable duplicate file detection false
--csv [filename] Export results to CSV file undefined
--csv-large [filename] Export large files to CSV undefined
--csv-duplicates [filename] Export duplicates to CSV undefined
--progress Show progress bar during analysis true
--no-progress Disable progress bar -
--max-depth <depth> Maximum directory depth to scan -1 (no limit)
-c, --config [path] Load configuration from file undefined
-h, --help Display help information -
-V, --version Display version number -

Configuration Files

You can save analysis settings in a configuration file to avoid repeating command-line options. The tool looks for configuration files in the following order:

  1. .dir-analysis-tool.json in the current directory
  2. dir-analysis-tool.config.json in the current directory
  3. Searches parent directories up to the root

Configuration File Example

{
  "excludePatterns": ["*.log", "temp*", ".cache"],
  "largeSizeThreshold": 52428800,
  "enableDuplicateDetection": true,
  "enableProgressBar": true,
  "outputFormat": "table",
  "maxDepth": 10
}

Configuration Options

Option Type Description Default
excludePatterns string[] File patterns to exclude []
largeSizeThreshold number Large file threshold in bytes 104857600 (100MB)
enableDuplicateDetection boolean Enable duplicate detection false
enableProgressBar boolean Show progress indicators true
outputFormat string Output format (table, json, csv) table
maxDepth number Maximum scan depth (-1 = no limit) -1

File Type Classification

The tool automatically classifies files into the following categories:

Type Extensions
Images .png, .jpg, .jpeg, .gif, .svg, .webp, .bmp, .tiff, .ico
Videos .mp4, .mkv, .avi, .mov, .webm, .flv, .wmv, .m4v
Documents .pdf, .docx, .xlsx, .pptx, .txt, .doc, .xls, .ppt, .rtf, .odt, .ods, .odp
Audio .mp3, .wav, .flac, .aac, .ogg, .wma, .m4a
Code .js, .ts, .jsx, .tsx, .py, .java, .cpp, .c, .h, .hpp, .cs, .php, .rb, .go, .rs, .swift, .kt, .scala, .clj, .sh, .bat, .ps1, .sql, .html, .css, .scss, .sass, .less, .json, .xml, .yaml, .yml, .toml, .ini, .cfg, .conf
Archives .zip, .rar, .7z, .tar, .gz, .bz2, .xz, .tar.gz, .tar.bz2
Other All other file types

Output Examples

Terminal Output

๐Ÿ” Starting directory analysis...
[โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] 100% (1,247/1,247) /path/to/file.js
โœ… Analysis complete!

๐Ÿ“‚ Directory: ./my-project
๐Ÿ“ฆ Total Size: 124.7 MB
๐Ÿ“ Folders: 17
๐Ÿ“„ Files: 328

๐Ÿ—‚ File Types:
  ๐Ÿ“ท Images: 87
  ๐ŸŽฌ Videos: 4
  ๐Ÿ“„ Documents: 12
  ๐ŸŽต Audio: 8
  ๐Ÿง‘โ€๐Ÿ’ป Code: 165
  ๐Ÿ—ƒ๏ธ Archives: 3
  โ“ Other: 49

๐Ÿšจ Large Files (Top 5):
  ๐Ÿ“ assets/video/demo.mp4 - 45.2 MB
  ๐Ÿ“ dist/bundle.min.js - 12.8 MB
  ๐Ÿ“ docs/manual.pdf - 8.4 MB
  ๐Ÿ“ src/data/dataset.json - 5.9 MB
  ๐Ÿ“ assets/images/banner.png - 3.2 MB

๐Ÿ”„ Duplicate Files:
  ๐Ÿ“Š Groups: 8
  ๐Ÿ’พ Wasted Space: 156.8 MB

  Top duplicate groups:
  1. 23.4 MB each ร— 4 files
     ๐Ÿ“„ backup/project-v1.zip
     ๐Ÿ“„ archives/project-backup.zip
     ... and 2 more
  2. 12.8 MB each ร— 3 files
     ๐Ÿ“„ dist/bundle.min.js
     ๐Ÿ“„ build/main.js
     ... and 1 more

JSON Output

{
  "path": "./my-project",
  "totalSizeBytes": 130861056,
  "totalSizeMB": 124.7,
  "folders": 17,
  "files": 328,
  "types": {
    "images": 87,
    "videos": 4,
    "documents": 12,
    "audio": 8,
    "code": 165,
    "archives": 3,
    "other": 49
  },
  "largeFiles": [
    {
      "path": "/project/assets/video/demo.mp4",
      "size": 47430656,
      "sizeFormatted": "45.2 MB"
    }
  ],
  "duplicateGroups": [
    {
      "hash": "a1b2c3d4...",
      "size": 24543232,
      "sizeFormatted": "23.4 MB",
      "files": [
        "/project/backup/project-v1.zip",
        "/project/archives/project-backup.zip"
      ],
      "totalWastedSpace": 24543232,
      "totalWastedSpaceFormatted": "23.4 MB"
    }
  ],
  "duplicateStats": {
    "totalGroups": 8,
    "totalWastedSpace": 164470938,
    "totalWastedSpaceFormatted": "156.8 MB"
  }
}

CSV Export

The tool can export data to CSV format for further analysis:

General Analysis CSV (--csv)

Type,Path,Size (Bytes),Size (Formatted),Count,Details
Summary,./my-project,130861056,124.7MB,328,Folders: 17
FileType,images,-,-,87,-
FileType,code,-,-,165,-
LargeFile,"/project/assets/video/demo.mp4",47430656,"45.2 MB",1,-
Duplicate,"/project/backup/project-v1.zip",24543232,"23.4 MB",1,"Group 1, Total files: 2, Wasted space: 23.4 MB"

Large Files CSV (--csv-large)

Path,Size (Bytes),Size (Formatted)
"/project/assets/video/demo.mp4",47430656,"45.2 MB"
"/project/dist/bundle.min.js",13421772,"12.8 MB"

Duplicates CSV (--csv-duplicates)

Group,Path,Size (Bytes),Size (Formatted),Files in Group,Wasted Space
1,"/project/backup/project-v1.zip",24543232,"23.4 MB",2,"23.4 MB"
1,"/project/archives/project-backup.zip",24543232,"23.4 MB",2,"23.4 MB"

Performance & Large Directories

For optimal performance when analyzing large directories:

  • Use --max-depth to limit scan depth
  • Use --exclude to skip unnecessary directories
  • Disable features you don't need (e.g., --no-progress, --no-types)
  • Use --no-recursive for single-level analysis

Default Exclusions

The following directories are excluded by default:

  • node_modules
  • .git
  • .svn
  • .hg
  • dist
  • build
  • .cache

You can add custom exclusions using the --exclude option or configuration file.

Phase 1 Features

File size filtering

# Show only files between 1MB and 10MB
dir-analysis-tool --min-size 1048576 --max-size 10485760

# Show only files larger than 50MB
dir-analysis-tool --min-size 52428800

Date range filtering

# Show files modified after January 1, 2024
dir-analysis-tool --date-from 2024-01-01

# Show files modified between two dates
dir-analysis-tool --date-from 2024-01-01 --date-to 2024-12-31

Tree view and top files

# Display directory structure as a tree
dir-analysis-tool --tree

# Show top 20 largest files
dir-analysis-tool --top-n 20

# Detect empty files
dir-analysis-tool --empty-files

Phase 2 Features

Interactive mode

# Start interactive exploration mode
dir-analysis-tool --interactive

Watch mode

# Monitor directory for changes
dir-analysis-tool --watch

# Watch with limited depth
dir-analysis-tool --watch --max-depth 3

HTML reports

# Generate HTML report with charts
dir-analysis-tool --html

# Generate HTML report with custom filename
dir-analysis-tool --html my-report.html

# Full analysis with HTML report
dir-analysis-tool --large-files --duplicates --top-n 15 --html complete-report.html

Advanced Usage Examples

Cleanup Large Projects

# Find large files and duplicates in a project
dir-analysis-tool --large-files 10485760 --duplicates --csv cleanup-report.csv

# Analyze with specific exclusions
dir-analysis-tool --exclude "node_modules" "*.log" "tmp*" --large-files --duplicates

CI/CD Integration

# Generate JSON report for automated processing
dir-analysis-tool --json --large-files --max-depth 3 > analysis-report.json

# Check for space usage with threshold
dir-analysis-tool --large-files 52428800 --csv-large large-files.csv

Documentation & Reporting

# Generate comprehensive CSV reports
dir-analysis-tool --csv analysis.csv --csv-large large.csv --csv-duplicates dupes.csv --large-files --duplicates

# Create project documentation
dir-analysis-tool --path ./src --types --json > project-structure.json

Requirements

  • Node.js >= 18.0.0

Development

# Install dependencies
pnpm install

# Build the project
pnpm build

# Run in development mode
pnpm dev --path ./test-directory

# Run the built version
pnpm start --path ./test-directory

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Roadmap

Phase 2 (Planned)

  • ๐Ÿ“ˆ Advanced Analytics: File age analysis, access patterns
  • ๐Ÿ” Search & Filter: Find files by criteria
  • ๐Ÿงน Cleanup Tools: Interactive duplicate removal
  • ๐Ÿ“Š Visualization: Charts and graphs for data representation
  • โšก Performance: Multi-threading and caching improvements

Phase 3 (Future)

  • ๐ŸŒ Web Interface: Browser-based analysis dashboard
  • ๐Ÿ”— Integration: Git integration, cloud storage analysis
  • ๐Ÿค– AI Features: Smart categorization and recommendations
  • ๐Ÿ“ฑ Mobile: React Native app for mobile analysis