find-files-by-extensions ( path extensions -- seq ) (original) (raw)

find-files-by-extensions ( path extensions -- seq )
Factor handbook » Input and output » Directory manipulation » Searching directories

Prev: find-files-by-extension ( path extension -- seq )

Vocabulary
io.directories

Inputs

path a pathname string
extensions a sequence of file extensions

Outputs

seq a sequence

Word description
Searches a directory for all files in the given list of extensions. File extensions and filenames are converted to lower-case and compared using the tail? word. File extensions should contain the period.

Examples

USING: io.directories ; "/" { ".jpg" ".gif" ".tiff" ".png" ".bmp" } find-files-by-extensions

Definition

USING: kernel sequences unicode ;

IN: io.directories

: find-files-by-extensions ( path extensions -- seq )
[ >lower ] map [ [ >lower ] ] dip
[ [ tail? ] with any? ] curry compose find-files ;