Skip to content

aayank13/rust-metadata-organizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metadata Organizer

A high-performance Rust CLI tool to scan directories, extract, and organize file metadata with concurrent processing, EXIF support, and flexible sorting options.

Features

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)

Installation

Prerequisites

  • Rust 1.70+ and Cargo

Build from Source

# 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-organizer

Install Globally

cargo install --path .

Usage

Basic Command

metadata-organizer [OPTIONS] <PATH>

Examples

Scan current directory (non-recursive):

metadata-organizer .

Scan directory recursively:

metadata-organizer -r ~/Documents

Sort by file size (largest first):

metadata-organizer -s size -r ~/Pictures

Sort by modification date:

metadata-organizer -s modified ~/Downloads

Custom output file:

metadata-organizer -o results.json ~/Projects

Scan and sort by file type:

metadata-organizer -r -s type ~/Music

Command Line Options

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

Output Format

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"
    }
  }
]

Architecture

Module Structure

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

Key Technologies

  • 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

Performance

  • 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

Error Handling

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

File Type Detection

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...

Platform Support

  • Linux
  • macOS
  • Windows

Contributing

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)

License

MIT License - feel free to use in your projects!

Acknowledgments

Built with Rust - blazingly fast and memory safe!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages