15 releases (8 breaking)

0.9.1 Jan 6, 2024
0.9.0 Dec 20, 2023
0.8.1 Dec 8, 2020
0.8.0 Mar 7, 2020
0.1.0 Feb 20, 2018

#24 in Filesystem

Download history 519288/week @ 2025-08-17 497834/week @ 2025-08-24 589675/week @ 2025-08-31 487076/week @ 2025-09-07 460160/week @ 2025-09-14 464817/week @ 2025-09-21 480266/week @ 2025-09-28 512421/week @ 2025-10-05 490325/week @ 2025-10-12 471660/week @ 2025-10-19 532379/week @ 2025-10-26 551262/week @ 2025-11-02 538421/week @ 2025-11-09 586306/week @ 2025-11-16 448256/week @ 2025-11-23 498024/week @ 2025-11-30

2,099,849 downloads per month
Used in 1,995 crates (103 directly)

MIT license

32KB
538 lines

GlobWalk

License crates.io

Recursively find files in a directory using globs.

This crate is now in a perpetual maintnance mode and new users should probably cosider using glob.

Comparison to the glob crate

This crate was origially written years ago, when glob was a very differet crate, before it was adopted by the rust-lang org.

Nowadays glob is much better, and overall better maintained, but there are a few features that it does not seem to have (based on glob 0.3.1):

  • The glob crate does not support having {a,b} in patterns.
  • globwalk can match several glob-patterns at the same time.
  • globwalk supports excluding results with !. (negative patterns)
  • glob searches for files in the current working directory, whereas globwalk starts at a specified base-dir.

Usage

To use this crate, add globwalk as a dependency to your project's Cargo.toml:

[dependencies]
globwalk = "0.9.1"

The following piece of code recursively find all png, jpg, or gif files:

extern crate globwalk;

use std::fs;

for img in globwalk::glob("*.{png,jpg,gif}").unwrap() {
    if let Ok(img) = img {
        println!("{:?}", img.path());
    }
}

See the documentation for more details.

Dependencies

~3.5–7MB
~126K SLoC