title: Clojure - Is it possible to increment a variable within a doseq statement?
body: <p>I am trying to iterate over a list of files in a given directory, and add an incrementing variable i = {1,2,3.....} to their names.</p>
  
  <p>Here is the code I have for iterating through the files and changing each file's name:</p>
  
  <pre><code>(defn addCounterToExtIn [d]
    (def i 0)
    (doseq [f (.listFiles (file d)) ] ; make a sequence of all files in d
      (if (and (not (.isDirectory f)) ; if file is not a directry and
               (= '(\. \i \n) (take-last 3 (.getName f))) ) ; if it ends with .in
        (fs/rename f (str d '/ i (.getName f)))))) ; add i to start of its name
  </code></pre>
  
  <p>I don't know how can I increment <code>i</code> as <code>doseq</code> iterates through each file. Alternatively, is there a better loop to use to achieve the desired result?</p>