Skip to content

RustedBytes/wav-files-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wav-files-stats

A lightweight Rust CLI tool to recursively scan a directory for WAV audio files, calculate their durations, and display pretty statistics like total duration, average, min, and max.

Features

  • Recursive Directory Scanning: Processes WAV files in subfolders using efficient traversal.
  • Duration Calculation: Reads WAV headers to compute precise durations without full file loading.
  • Robust Error Handling: Skips invalid files gracefully and reports warnings.
  • Pretty Output: Formatted stats for quick insights.
  • Idiomatic Rust: Built with safety, concurrency primitives, and minimal dependencies.

Installation

Add as a binary crate or install via Cargo:

cargo install --git https://github.com/RustedBytes/wav-files-stats

For development, clone the repo and build:

git clone https://github.com/RustedBytes/wav-files-stats
cd wav-duration-stats
cargo build --release

Usage

wav-duration-stats /path/to/audio/folder

Example Output

WAV File Statistics:
====================
Total files processed: 5
Total duration: 12m 34s
Average duration: 2m 28s
Shortest file: 45s
Longest file: 4m 12s

Warnings:
  - Failed to read WAV file subfolder/invalid.wav: Invalid format

Testing

Run the test suite:

cargo test

Tests cover duration calculation (valid/empty/invalid files) and stats printing (with/without files). Uses tempfile for isolated fixtures.

Dependencies

  • clap: Argument parsing.
  • hound: WAV file reading.
  • walkdir: Recursive directory traversal.
  • anyhow: Error handling.

See Cargo.toml for versions.

Contributing

  1. Fork the repo.
  2. Create a feature branch (git checkout -b feature/AmazingFeature).
  3. Commit changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.