GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Bob Dylan Quotes+       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. Language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


duplicate-files.el

    

;;; duplicate-files.el

;; Copyright (C) 2006-2016 Davin Pearson

;; Author/Maintainer: Davin Max Pearson <http://davin.50webs.com>
;; Version: 1.17
;; Package-Requires: ()
;; Keywords: Duplicate files
;; URL: http://davin.50webs.com/research/2006/mopa2e.html#duplicate-files

;;; Commentary:

;; This file is not part of GNU Emacs.

;; This file copies files from ~/bak to g:/home/bak and h:/home/bak

;;; Limitation of Warranty


;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs, see the file COPYING.  If not, see:
;;
;; <http://www.gnu.org/licenses/gpl-3.0.txt>.


;;; Install Instructions:

;; See the following URL for the latest info and a tarball:
;;
;; <http://davin.50webs.com/research/2006/mopa2e.html#duplicate-files>
;;
;; Then untar the tarball to a folder pointed to by the Emacs variable
;; load-path and add the following line to your ~/.emacs file.
;;
;; (require 'duplicate-files)

;;; Known Bugs:

;; None!

;;; Code:

;; (setq source-dir "~/bak/")
;; (setq destination-dir "/media/www/C1TB/home/bak/")
;; (setq destination-dir "/media/www/F2TB/home/bak/")
;; (setq extension ".tar.gz")
;; (setq d-message-on t)
(defun duplicate-files-inner (source-dir destination-dir extension)
  ;;(let (list1 ptr list2 ptr2 rqe (d-message-on t))
  (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                 ;;;          Y    Y    Y    Y    M    M    D    D     h    h    m    m    s    s
      (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
      ;;(debug "schmu")
      (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)
Back
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Bob Dylan Quotes+ | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. Language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
| More Occam's Razor | C to Java Translator | Theory of Morality II
Last modified: Sat Apr 29 18:38:39 NZST 2017
Best viewed at 800x600 or above resolution.
© Copyright 1999-2017 Davin Pearson.
Please report any broken links to