Skip to content

Instantly share code, notes, and snippets.

@bhenry
Created July 23, 2010 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhenry/487537 to your computer and use it in GitHub Desktop.
Save bhenry/487537 to your computer and use it in GitHub Desktop.
(ns slideshow.images
(:use [clojure.java.io :only [copy file input-stream output-stream]])
(:import [java.io File FileReader FileWriter]))
(defn get-files [dir]
(let [data (filter #(.isFile #^File %)
(file-seq (java.io.File. dir)))]
(sort-by #(.lastModified %) < data)))
(defn get-images [dir]
(filter #(re-find #"(?i)[.](gif|jpg|png)$" (.getName %)) (get-files dir)))
(defn copy-imgs [dir]
(let [imgs (get-images dir)]
(for [img imgs]
(with-open [i (input-stream img)
o (output-stream (file "static"
"copies"
(.getName img)))]
(copy i o)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment