duplicate-files
(defun duplicate-files-inner (source-dir destination-dir extension)
(progn
(cull-same-dates-dir-plus-extension destination-dir extension)
(message "cull-same-dates destination-dir=%s" destination-dir)
(cull-size-quota-dir-plus-extension destination-dir extension)
(message "cull-size-quota-dir-plus-extension destination-dir=%s extension=%s" destination-dir extension)
(assert (or (string= ".tar.gz" extension)
(string= ".tar" extension)
(string= ".zip" extension)))
(setq rqe (concat (regexp-quote extension) "$"))
(message "source-dir=%s destination-dir=%s" source-dir destination-dir)
(sit-for 1)
(setq list1 (directory-files source-dir nil rqe t))
(setq list1 (sort list1 'string<-ignore-case))
(setq ptr list1)
(while ptr (when (string-match (concat "^\\(.*\\)[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]" rqe) (car ptr))
(setcar ptr (substring (car ptr) (match-beginning 1) (match-end 1))))
(setq ptr (cdr ptr)))
(setq list1 (delete-duplicates list1 :test 'string=))
(setq ptr list1)
(while ptr
(setq list2 (directory-files source-dir nil (concat "^" (regexp-quote (car ptr)) ".*" rqe) t))
(setq list2 (sort list2 'string<-ignore-case))
(setq ptr2 list2)
(while ptr2
(when (not (file-exists-p (concat destination-dir (car ptr2))))
(safe-command (copy-file (concat source-dir (car ptr2)) (concat destination-dir (car ptr2)) 'OK-if-ALREADY-EXISTS 'KEEP-TIME) 'QUIET)
(message "copying file %s -> %s" (concat source-dir (car ptr2)) (concat destination-dir (car ptr2)))
)
(setq ptr2 (cdr ptr2)))
(cull-same-dates-dir-plus-extension destination-dir extension)
(message "cull-same-dates destination-dir=%s" destination-dir)
(cull-size-quota-dir-plus-extension destination-dir extension)
(message "cull-size-quota-dir-plus-extension destination-dir=%s extension=%s" destination-dir extension)
(setq ptr (cdr ptr)))
)
)
(defun duplicate-files ()
(interactive)
(progn
(datify--dir "~/bak")
(cull-same-dates "~/bak")
(cull-size-quota "~/bak")
(safe-command (make-directory "/media/www/G16GB/home/bak/" 'parents))
(duplicate-files-inner "~/bak/" "/media/www/F2TB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/F2TB/home/bak/" ".zip")
(duplicate-files-inner "~/bak/" "/media/www/G16GB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/G16GB/home/bak/" ".zip")
(duplicate-files-inner "~/bak/" "/media/www/H16GB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/H16GB/home/bak/" ".zip")
(duplicate-files-inner "~/bak/" "/media/www/K2TB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/K2TB/home/bak/" ".zip")
(duplicate-files-inner "~/bak/" "/media/www/BLU16GB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/BLU16GB/home/bak/" ".zip")
(duplicate-files-inner "~/bak/" "/media/www/GRN16GB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/GRN16GB/home/bak/" ".zip")
(when (file-exists-p "/media/www/WD2TB")
(duplicate-files-inner "~/bak/" "/media/www/WD2TB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/WD2TB/home/bak/" ".zip")
)
(when (file-exists-p "/media/www/WD2TB2")
(duplicate-files-inner "~/bak/" "/media/www/WD2TB2/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/WD2TB2/home/bak/" ".zip")
)
(when (file-exists-p "/media/www/C1TB")
(duplicate-files-inner "~/bak/" "/media/www/C1TB/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "/media/www/C1TB/home/bak/" ".zip")
)
(when (file-exists-p "f:/")
(duplicate-files-inner "~/bak/" "f:/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "f:/home/bak/" ".zip")
)
(when (file-exists-p "h:/")
(duplicate-files-inner "~/bak/" "h:/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "h:/home/bak/" ".zip")
)
(when (file-exists-p "j:/")
(duplicate-files-inner "~/bak/" "j:/home/bak/" ".tar.gz")
(duplicate-files-inner "~/bak/" "j:/home/bak/" ".zip")
)
(when (and (file-exists-p "c:/") (file-exists-p "f:/"))
(duplicate-files-inner "c:/davinpearson-com/binaries/" "f:/davinpearson-com/binaries/" ".tar.gz")
(duplicate-files-inner "c:/davinpearson-com/binaries/" "f:/davinpearson-com/binaries/" ".zip")
)
)
)
(provide 'duplicate-files)