Mercurial > lasercutter
view src/clojureDemo/sys_utils.clj @ 6:4ae2497acf7d
saving progress
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 20 Aug 2010 03:18:05 -0400 |
parents | 6d9bdaf919f7 |
children |
line wrap: on
line source
2 (ns clojureDemo.sys-utils4 (:use [clojure.contrib duck-streams str-utils shell-out])5 (:import java.io.File)6 )10 (defn rename [file]12 (if (re-matches #".*\.JPG$" (str file))13 (sh "mv" (str file) (re-sub #"\.JPG" ".jpg" (str file)))14 nil))19 (defn escape-spaces20 [string]21 (re-gsub #" " (str \-) string))24 (defn view25 [string]26 (seq (char-array string)))28 (defn parent-source [target file]29 (File. (str target "/" (.getName (.getParentFile file))"-" (.getName file))))32 (defn rsync [file1 file2]33 (let [*out* nil]34 (sh "rsync" "-avz" (str file1) (escape-spaces(str file2)))))36 (defn shunt-file [target file]37 (rsync (str file) (str (parent-source target file))))41 (defn extract-files42 [regex source destination]44 (dorun (map (partial shunt-file destination)45 (filter (comp not nil? (partial re-matches regex) str) (file-seq source)))))48 (defn file-count [#^java.io.File file]49 (count (file-seq file)))54 (comment56 (defn test-extract57 []58 ((partial extract-files #".*\.JPG"59 (file-str " /home/r/Desktop/judy_yates_computer_archive/MyDocuments/dallas townhome")60 (file-str "/home/r/Desktop/judyates_admin/archive-source-images/"))))63 (defn judy-jpg-extract64 []65 ((partial extract-files #".*\.JPG"66 (file-str "/home/r/Desktop/judy_yates_computer_archive")67 (file-str "/home/r/Desktop/judyates_admin/archive-source-images/"))))69 )