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.
- 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.
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
wav-duration-stats /path/to/audio/folder
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
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.
clap
: Argument parsing.hound
: WAV file reading.walkdir
: Recursive directory traversal.anyhow
: Error handling.
See Cargo.toml
for versions.
- Fork the repo.
- Create a feature branch (
git checkout -b feature/AmazingFeature
). - Commit changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a Pull Request.