           (copy-obi-project!)
           (create-obi-config-file!)))))
 
-(def recording-productions-without-obi
-  "All productions with state \"recording\" with wav files but no obi project"
-  (filter #(not (contains-obi-project (get-all-files %)))
-          recording-productions-with-wav))
-
 (defn create-recording-productions-without-obi!
   "Create all productions with state \"recording\" with wav files that
   do not contain an obi project. Add to the db and create the directories"
-  []
-  (doseq [p recording-productions-without-obi]
+  [productions]
+  (doseq [p (filter recording-with-wav-no-obi? productions)]
     (-> p
         prod/create!
         prod/set-state-structured!

          (copy-struct-file!)
          (convert-struct-file!)))))

(def recording-productions-with-wav
  "All productions with state \"recording\" that contain wav files"
  (filter #(and (= (:state %) "recording")
                (contains-wav-files (get-all-files %)))
          all-productions))

(def recording-productions-with-obi
  "All productions with state \"recording\" with wav files that contain an obi project"
  (filter #(contains-obi-project (get-all-files %))
          recording-productions-with-wav))

(defn create-recording-productions-with-obi!
  "Create all productions with state \"recording\" with wav files that
  contain an obi project. Add to the db and create the directories.
  Copy the obi project to the new place. Place an obi config file
  inside the obi project"
  []
  (doseq [p recording-productions-with-obi]
    (-> p
        prod/create!
        prod/set-state-structured!

  "Print a summary of all the productions that are about to be migrated"
  []
  (println "Migrating productions from old to new Madras")
  (println "============================================")
  (println)
  (println "Importing from ABACUS")
  (println "~~~~~~~~~~~~~~~~~~~~~")
  (println)
  (println "Ready:" (count (filter ready? all-productions)))
  (println "-----")
  (println (string/join ", " (map :id (filter ready? all-productions))))
  (println)
  (println "Archived:" (count (filter archived? all-productions)))
  (println "--------")
  (println)
  (println "Recording with no wav and a struct.html:" (count (filter #(recording-no-wav-with-struct? %) all-productions)))
  (println "---------------------------------------")
  (println (string/join ", " (map :id (filter #(recording-no-wav-with-struct? %) all-productions))))
  (println)
  (let [weird (filter #(and (not-any? struct-file? (get-all-files %)) (recording-no-wav? %)) all-productions)]
    (println "Recording with no wav and no struct.html:" (count weird))
    (println "----------------------------------------")
    (println (string/join ", " (map :id weird))))
  (println)
  (println "Recording with wav and an obi project:" (count (filter recording-with-obi? all-productions)))
  (println "-------------------------------------")
  (println (string/join ", " (map :id (filter recording-with-obi? all-productions))))
  (println)
  (println "Recording with wav and no obi project:" (count (filter recording-with-wav-no-obi? all-productions)))
  (println "-------------------------------------")
  (println (string/join ", " (map :id (filter recording-with-wav-no-obi? all-productions))))
  (println)
  (println "Ignoring the rest")
  (println (dissoc (frequencies (map :state all-productions)) "archived" "recording" "ready"))
