Created
October 13, 2021 19:09
-
-
Save paulspencerwilliams/ea44abf09891aacafb594d8d0262d894 to your computer and use it in GitHub Desktop.
Simple ns that lists files that are in one folder but not another, or different in both
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
(ns ensure-all-there.core | |
(:use clojure.data) | |
(:require [clj-commons.digest :as digest])) | |
(def jpgs-path "/Users/will/Pictures/New photography workflow/1_ingest_and_cull/jpgs-from-lightroom") | |
(def originals-path "/Volumes/RAID/photography/originals") | |
(defn files-in [folder] | |
(->> folder | |
clojure.java.io/file | |
file-seq | |
(drop 1) | |
(reduce (fn [m f] | |
(assoc m (.getName f) (digest/sha-256 f))) {}))) | |
(defn only-in [f1 f2] | |
(let [first-files (files-in f1) | |
second-files (files-in f2) | |
only-in-first (first (diff | |
(->> first-files | |
keys | |
set) | |
(->> second-files | |
keys | |
set)))] | |
{:only-in-first (seq only-in-first) | |
:different-in-first (->>(diff first-files second-files) | |
first | |
(filter (fn [[k v]] (not (contains? only-in-first k)))) | |
keys)})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment