Liking cljdoc? Tell your friends :D


Clojars Project bb built-in

File system utilities. This library can be used on the JVM and is also included in babashka (>= 0.2.9).


Babashka is a scripting utility. It's convenient to have cross platform file system utilities available for scripting. The namespace already offers a bunch of useful features, but it predates java.nio. The nio package isn't that nice to use from Clojure and this library should help with that.

The main inspirations for this library are, clj-commons/fs and corasaurus-hex/fs.

API docs



(require '[babashka.fs :as fs])
(fs/directory? ".") ;;=> true


The glob function takes a root path and a pattern. The pattern is interpreted as documented here.

(map str (fs/glob "." "**{.clj,cljc}"))


("project.clj" "test/babashka/fs_test.clj" "src/babashka/fs.cljc")

The function exec-paths returns all entries from PATH as Paths. To search all these directories for an executable, e.g. java, you can combine it with list-dirs which searches files directly in the directories using an (optional) glob pattern:

(str (first (filter fs/executable? (fs/list-dirs (filter fs/exists? (fs/exec-paths)) "java"))))

For convenience, the above use case is also supported using the which function:

(str (fs/which "java"))


$ bb test


Copyright © 2020-2021 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.

Can you improve this documentation? These fine people already did:
Michiel Borkent, Lee Read, Alex Sheluchin & Cora Sutton
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close