Skip to content

Instantly share code, notes, and snippets.

@tjennings
Created December 10, 2009 23:17
Show Gist options
  • Save tjennings/253799 to your computer and use it in GitHub Desktop.
Save tjennings/253799 to your computer and use it in GitHub Desktop.
(require ['clojure.contrib.shell-out :as 'shell])
(def dir (second *command-line-args*))
(defn as-seq [str]
(seq (.split str "\n")))
(defn find-by-name [d n] (as-seq (shell/sh "find" "." "-name" n :dir d)))
(defn oggs [] (as-seq (shell/sh "find" "." "-name" "*.ogg" :dir dir)))
(defn indexed [coll] (map vector (iterate inc 0) coll))
(defn map-with-index
[fun coll]
(map #(apply fun %) (indexed coll)))
(defn doprint
[coll]
(let [formatted (fn [idx st] (str "[" idx "] " st))]
(doseq [file (map-with-index formatted coll)] (println file))))
;(defn directories
; [s]
; (map #(drop-last (.split % "/"))))
;
(doprint (find-by-name "./" "*.clj"))
;(directories (oggs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment