Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle initial renames where there is nothing there to discern a temp…

…late.
  • Loading branch information...
commit 9329b11175ea2a267e41a7c7f1d86d150f458031 1 parent ac2ff27
@Raynes authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/mkvrename/core.clj
View
16 src/mkvrename/core.clj
@@ -7,15 +7,27 @@
(defn rename [template n f]
(let [new-file (file cd (str template n ".mkv"))]
- (println (str "Renaming " f " to " new-file))
+ (println (str "Renaming " (.getName f) " to " (.getName new-file)))
(.renameTo f new-file)))
+(defn prompt-read [& strs]
+ (map (fn [s]
+ (print s)
+ (flush)
+ (read-line))
+ strs))
+
+(defn template [f]
+ (if f
+ (re-find #".*- S\d+E" (.getName f))
+ (apply format "%s - S%sE" (prompt-read "Show Title: " "This Season: "))))
+
(defn -main [& args]
(let [[new done] (separate #(.startsWith (.getName %) "title")
(filter (comp (partial re-find #".*\.mkv") str)
(file-seq (file cd))))
done-count (inc (count done))
- template (re-find #".*- S\d+E" (.getName (first done)))]
+ template (template (first done))]
(doall
(map (partial rename template)
(range done-count (+ (count new) done-count))
Please sign in to comment.
Something went wrong with that request. Please try again.