Created
January 13, 2014 19:58
-
-
Save ciaranarcher/8406880 to your computer and use it in GitHub Desktop.
Concatenate any number of files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn cat-many [out files] | |
(map #(with-open [o (io/output-stream out)] | |
(io/copy (io/file %) o)) files)) | |
(cat-many "/tmp/ciaran.mp3" '("/tmp/test-recording-1.mp3" "/tmp/test-recording-2.mp3")) |
you want to wrap the file processing within the with-open
. Then you don't need the :append
since you won't be opening and closing the file each time. So, something like
(defn cat> [files outfile]
(with-open [out (jio/output-stream outfile)]
(doseq [f files]
(jio/copy (jio/file f) out))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i managed to make it work by adding the option
:append true