Created
August 2, 2015 16:22
-
-
Save n3dst4/c68f9faacd61218037f3 to your computer and use it in GitHub Desktop.
DW sorter
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
| (defn episode-number [file] | |
| (def match (re-matches | |
| #"\d{4}-\d{2}-\d{2} - (S\d\d E\d\d) - .*" | |
| (.getName file))) | |
| (if (= match nil) | |
| nil | |
| (match 1))) | |
| (def episodes (partition-by episode-number files)) | |
| (defn process-episode [s] | |
| (def this-episode-number (episode-number (nth s 0))) | |
| (def folder-name (str dw-path this-episode-number "\\")) | |
| (io/make-parents (str folder-name "x")) | |
| (doseq [f s] | |
| (def new-name (str folder-name (.getName f))) | |
| (println "Moving " (.getAbsolutePath f) " to " new-name) | |
| (.renameTo (.getAbsoluteFile f) (io/file new-name)))) | |
| ;(def episodes (take 3 episodes)) | |
| (doseq [e episodes] | |
| (process-episode e)) | |
| (defn -main | |
| "I don't do a whole lot ... yet." | |
| [& args] | |
| (println "Hello, World!")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment