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-toolUsing npx (no installation)
npx dir-analysis-tool [options]Local development
git clone <repository>
cd dir-analysis-tool
pnpm install
pnpm buildUsage
Basic usage
dir-analysis-toolAnalyze a specific directory
dir-analysis-tool --path /path/to/directoryEnable large file detection (100MB threshold)
dir-analysis-tool --large-filesCustom large file threshold (50MB)
dir-analysis-tool --large-files 52428800Enable duplicate detection
dir-analysis-tool --duplicatesExport 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.csvUse configuration file
dir-analysis-tool --config ./my-config.jsonCombine multiple features
dir-analysis-tool --path /my/project --large-files --duplicates --csv --progress --max-depth 5Get JSON output
dir-analysis-tool --jsonDisable recursive scanning
dir-analysis-tool --no-recursiveExclude 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:
.dir-analysis-tool.jsonin the current directorydir-analysis-tool.config.jsonin the current directory- 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 moreJSON 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-depthto limit scan depth - Use
--excludeto skip unnecessary directories - Disable features you don't need (e.g.,
--no-progress,--no-types) - Use
--no-recursivefor single-level analysis
Default Exclusions
The following directories are excluded by default:
node_modules.git.svn.hgdistbuild.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 52428800Date 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-31Tree 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-filesPhase 2 Features
Interactive mode
# Start interactive exploration mode
dir-analysis-tool --interactiveWatch mode
# Monitor directory for changes
dir-analysis-tool --watch
# Watch with limited depth
dir-analysis-tool --watch --max-depth 3HTML 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.htmlAdvanced 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 --duplicatesCI/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.csvDocumentation & 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.jsonRequirements
- 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-directoryLicense
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