Skip to content

Instantly share code, notes, and snippets.

@devrimbaris
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devrimbaris/7ea9931c03934e97b898 to your computer and use it in GitHub Desktop.
Save devrimbaris/7ea9931c03934e97b898 to your computer and use it in GitHub Desktop.
Git command generator for indexed filename renamer
;;Renames file by adding file numbers incrementally
;;To run, execute repl output in shell
(ns dba.core.utils
(:require [clojure.java.io :as io]
[clojure.string :as stri]))
(defn- pad-left [s p length]
(stri/replace (format
(str "%" length "s" )
s) " " p))
(map println (map #(str "git mv \"" (.getName %1) "\" " "\""
(pad-left %2 "0" 4)
"_"(.getName %1) "\"" )
(.listFiles (io/file "FILEPATH"))
(range)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment