Created
July 23, 2010 14:53
-
-
Save bhenry/487537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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