Created
March 24, 2016 21:13
-
-
Save MichaelBlume/ccce1b7487adee85d1ee to your computer and use it in GitHub Desktop.
drops all messages older than some date from a textsecure backup
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
(def cutoff | |
(clj-time.coerce/to-long | |
(clj-time.core/date-time 2015 4 3 5 54))) | |
(with-open [input (java.io.FileInputStream. | |
"/Users/michael.blume/TextSecurePlaintextBackup.xml") | |
output (java.io.FileWriter. | |
"/Users/michael.blume/betterbackup.xml")] | |
(-> input | |
clojure.data.xml/parse | |
(update-in [:content] (fn [messages] | |
(filter #(-> % :attrs :date Long/parseLong (> cutoff)) messages))) | |
(clojure.data.xml/emit output) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment