   (:import (java.io File)))
 
 
+(defn abbreviate-path
+  "If the string pathname begins with the string to-abbrev (followed
+by the File path separator string), replace that portion of the path
+name with the abbreviation abbrev (followed by the FIle path separator
+string) and return that.  Otherwise return pathname."
+  [^String pathname to-abbrev abbrev]
+  (if (and (string? abbrev)
+           (.startsWith pathname (str to-abbrev File/separator)))
+    (str abbrev (subs pathname (count to-abbrev)))
+    pathname))
+
+
 (defn copy-ns-file
   "Copies the .clj source file (found relative to source-path) for the
 namespace named by the symbol ns-sym to a file for the same namespace,

  sure you have a backup or version control."
  [old-sym new-sym source-path dest-path dirs opts]
  ;; TBD: Add dry run option
  (move-ns-file old-sym new-sym source-path dest-path)
  (doseq [file (#'move/clojure-source-files dirs)]
    (update-file opts file replace-ns-symbol old-sym new-sym)))



  WARNING: This function moves and deletes your source files!  Make
  sure you have a backup or version control."
  [old-sym new-sym source-path dest-path opts]
  (let [old-file (io/file source-path (#'move/ns-file-name old-sym))
        new-file (io/file dest-path (#'move/ns-file-name new-sym))]
    (when (:print? opts)
      (println (format "mkdir %s"
                       (abbreviate-path (str (.getParentFile new-file))
                                        dest-path (:dest-path-abbrev opts)))))
    (when-not (:dry-run? opts)
      (.mkdirs (.getParentFile new-file)))
    (when (:print? opts)
      (println (format "copy %s %s"
                       (abbreviate-path (str old-file)
                                        source-path (:source-path-abbrev opts))
                       (abbreviate-path (str new-file)
                                        dest-path (:dest-path-abbrev opts)))))
    (when-not (:dry-run? opts)
      (io/copy old-file new-file))
    (when (:print? opts)
      (println (format "delete %s"
                       (abbreviate-path (str old-file)
                                        source-path (:source-path-abbrev opts)))))
    (when-not (:dry-run? opts)
      (.delete old-file))
    (when (:print? opts)
      (println (format "delete old dir %s if empty"
                       (abbreviate-path (str (.getParentFile old-file))
                                        source-path (:source-path-abbrev opts)))))
    (when-not (:dry-run? opts)
      (loop [dir (.getParentFile old-file)]
        (when (empty? (.listFiles dir))
          (.delete dir)
          (recur (.getParentFile dir)))))))


(defn replace-ns-symbol
