Skip to content

Instantly share code, notes, and snippets.

@LukasRychtecky
Created July 3, 2023 13:04
Show Gist options
  • Save LukasRychtecky/1503c085232d2a27da4e4d52b6b51b12 to your computer and use it in GitHub Desktop.
Save LukasRychtecky/1503c085232d2a27da4e4d52b6b51b12 to your computer and use it in GitHub Desktop.
A script for extracting attachments from ZFO files
(import '[java.util Base64])
(let [decode-base64 #(.decode (Base64/getDecoder) %)
path "/my/input/zfo.xml"
output-dir "/my/output/dir/"
parsed (-> path io/file io/input-stream xml/parse)
files
(->> parsed
:content
first
:content
first
:content
(filter (comp (partial = :dmFiles) :tag))
first
:content
(map (juxt (comp :dmFileDescr :attrs) (comp first :content first :content))))]
(with-open [w (io/output-stream (str output-dir (ffirst files)))]
(.write w (-> files first second (string/replace "\n" "") decode-base64)))
(map first files)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment