A high-performance Rust CLI tool to scan directories, extract, and organize file metadata with concurrent processing, EXIF support, and flexible sorting options.
Comprehensive Metadata Extraction
- File name, size, type, and MIME type
- Creation, modification, and access timestamps
- File permissions
- EXIF data for images (camera info, GPS, dimensions, etc.)
High Performance
- Concurrent file processing using Tokio async runtime
- Controlled parallelism with semaphore (50 concurrent operations)
- Progress bar with real-time updates
- Optimized for large directory structures
Flexible Options
- Recursive or single-level directory scanning
- Multiple sorting criteria (name, size, type, date)
- Structured JSON export
- Cross-platform support (Windows, macOS, Linux)
- Rust 1.70+ and Cargo
# Clone or create the project directory
mkdir metadata-organizer && cd metadata-organizer
# Copy all the provided files:
# - Cargo.toml
# - src/main.rs
# - src/cli.rs
# - src/error.rs
# - src/metadata.rs
# - src/scanner.rs
# - src/sorter.rs
# Build in release mode
cargo build --release
# The binary will be at target/release/metadata-organizercargo install --path .metadata-organizer [OPTIONS] <PATH>Scan current directory (non-recursive):
metadata-organizer .Scan directory recursively:
metadata-organizer -r ~/DocumentsSort by file size (largest first):
metadata-organizer -s size -r ~/PicturesSort by modification date:
metadata-organizer -s modified ~/DownloadsCustom output file:
metadata-organizer -o results.json ~/ProjectsScan and sort by file type:
metadata-organizer -r -s type ~/Music| Option | Short | Description | Default |
|---|---|---|---|
<PATH> |
Directory path to scan | Required | |
--recursive |
-r |
Recursively scan subdirectories | false |
--sort-by |
-s |
Sort criteria: name, size, type, created, modified |
name |
--output |
-o |
Output JSON file path | metadata.json |
The tool generates a structured JSON file with detailed metadata for each file:
[
{
"name": "photo.jpg",
"path": "/home/user/Pictures/photo.jpg",
"size": 2458624,
"file_type": "Image",
"mime_type": "image/jpeg",
"created": "2024-01-15T10:30:45Z",
"modified": "2024-01-15T10:30:45Z",
"accessed": "2024-10-23T14:22:10Z",
"is_file": true,
"is_dir": false,
"extension": "jpg",
"permissions": "644",
"exif_data": {
"camera_make": "Canon",
"camera_model": "EOS 5D Mark IV",
"date_taken": "2024:01:15 10:30:45",
"width": 6720,
"height": 4480,
"iso": "400",
"focal_length": "50 mm",
"f_number": "f/2.8",
"exposure_time": "1/125"
}
}
]metadata-organizer/
├── src/
│ ├── main.rs # Entry point and orchestration
│ ├── cli.rs # Command-line argument parsing
│ ├── error.rs # Custom error types
│ ├── metadata.rs # Metadata extraction and EXIF parsing
│ ├── scanner.rs # Concurrent directory scanning
│ └── sorter.rs # Metadata sorting algorithms
└── Cargo.toml # Dependencies and project config
- Tokio: Async runtime for concurrent I/O operations
- kamadak-exif: EXIF metadata extraction from images
- Serde/Serde JSON: Structured data serialization
- Chrono: Date and time handling
- Clap: Command-line argument parsing
- WalkDir: Efficient directory traversal
- Indicatif: Progress bars and spinners
- Concurrent Processing: Up to 50 files processed simultaneously
- Memory Efficient: Streaming approach for large directories
- Fast Sorting: In-memory sorting with optimized algorithms
- Error Resilient: Continues processing even if individual files fail
The tool implements robust error handling:
- Permission denied errors are logged but don't stop execution
- Corrupted files are skipped with warnings
- EXIF extraction failures are handled gracefully
- Network drives and special files are safely processed
Supports intelligent categorization:
- Images: jpg, png, gif, bmp, webp, svg
- Videos: mp4, avi, mov, mkv, webm
- Audio: mp3, wav, flac, aac, ogg
- Documents: pdf, doc, docx, txt
- Code: rs, py, js, java, c, cpp
- Archives: zip, rar, 7z, tar, gz
- And many more...
- Linux
- macOS
- Windows
Contributions are welcome! Areas for improvement:
- Additional metadata formats (video, audio)
- Database export options (SQLite, PostgreSQL)
- Filtering capabilities
- Duplicate file detection
- File integrity verification (checksums)
MIT License - feel free to use in your projects!
Built with Rust - blazingly fast and memory safe!