Created
July 3, 2023 13:04
-
-
Save LukasRychtecky/1503c085232d2a27da4e4d52b6b51b12 to your computer and use it in GitHub Desktop.
A script for extracting attachments from ZFO files
This file contains 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
(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