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-utils
3 :use [clojure.contrib duck-streams str-utils shell-out]
4 :import java.io.File
5 )
10 (defn escape-spaces
11 [string]
12 (re-gsub #" " (str \-) string))
15 (defn view
16 [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-files
33 [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-extract
39 []
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-extract
46 []
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/"))))