Mercurial > lasercutter
view src/clojureDemo/sys-utils.clj~ @ 1:6d9bdaf919f7
added clojureDemo source
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 20 Aug 2010 00:32:44 -0400 |
parents | |
children |
line wrap: on
line source
1 (ns clojureDemo.sys-utils3 :use [clojure.contrib duck-streams str-utils shell-out]4 :import java.io.File5 )10 (defn escape-spaces11 [string]12 (re-gsub #" " (str \-) string))15 (defn view16 [string]17 (seq (char-array string)))19 (defn parent-source [target file]20 (File. (str target "/" (.getName (.getParentFile file))"-" (.getName file))))23 (defn rsync [file1 file2]24 (let [*out* nil]25 (sh "rsync" "-avz" (str file1) (escape-spaces(str file2)))))27 (defn shunt-file [target file]28 (rsync (str file) (str (parent-source target file))))32 (defn extract-files33 [regex source destination]35 (map (partial shunt-file destination)36 (filter (comp not nil? (partial re-matches regex) str) (file-seq source))))38 (defn test-extract39 []40 ((partial extract-files #".*\.JPG"41 (file-str " /home/r/Desktop/judy_yates_computer_archive/MyDocuments/dallas townhome")42 (file-str "/home/r/Desktop/judyates_admin/archive-source-images/"))))45 (defn judy-jpg-extract46 []47 ((partial extract-files #".*\.JPG"48 (file-str "/home/r/Desktop/judy_yates_computer_archive")49 (file-str "/home/r/Desktop/judyates_admin/archive-source-images/"))))