Learn how to find files recursively with file-seq.
- [Narrator] In this video, we'll implement…the part of our program…that will recursively find image files.…We'll use Clojure's built in file seek function…to implement this feature in a very simple manner.…I'm gonna double click the files.clj file…and first we'll implement our name space…with image-meta.files.…Then in a require expression, I'll require clojure.java.io…and then alias it to io…and we'll need this for some file operations.…
So to achieve this I'll start with a function,…I'm going to call it just find-files…and it's going to need to take a parameter.…I'll call it file-dir.…This'll be a string for the directory…that we're gonna search in.…For this function, I'm gonna use the thread last macro again…using the double arrowhead, and I'll start…by constructing a file instance using io/file…and passing it the file-dir that's given.…This'll create a file instance representing that directory…which we can pass to the built in function file-seq.…Given this file directory, file-seq will walk that directory…
Skill Level Intermediate
1. Problem 1: Exploring Lake Pend Oreille
2. Problem 2: Image Analysis
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Recursion and Directories
6. Problem 6: Building the Web
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.