
(defun copy-downloads ()
  (interactive)
  (setq c-downloads "/media/www/C1TB/Downloads/")
  (setq f-downloads "/media/www/CC8EF01C8EEFFD30/Downloads/")
  (let (ptr list len count)
    (setq list (directory-files-deep c-downloads))
    (setq ptr list)
    (setq len (length list))
    (setq count 0)
    (while ptr
      (make-directory (file-name-directory (concat f-downloads (car ptr))) 'PARENTS)
      (condition-case err
          (if (file-directory-p (concat f-downloads (car ptr)))
              (make-directory (concat f-downloads (car ptr)) 'PARENTS)
            (message "Copying file %s progress=%s" (car ptr) (/ (* 100 count) len))
            (copy-file (concat c-downloads (car ptr))
                       (concat f-downloads (car ptr))
                       nil
                       'KEEP-TIME))
        (error nil))
      (incf count)
      (setq ptr (cdr ptr))))
  (let (ptr list len count)
    (setq list (directory-files-deep f-downloads))
    (setq ptr list)
    (setq len (length list))
    (setq count 0)
    (while ptr
      (if (file-exists-p (concat c-downloads (car ptr)))
          (condition-case err
              (if (file-directory-p (concat c-downloads (car ptr)))
                  (make-directory (concat c-downloads (car ptr)) 'PARENTS)
                (message "Copying file %s progress=%s" (car ptr) (/ (* 100 count) len))
                (copy-file (concat f-downloads (car ptr))
                           (concat c-downloads (car ptr))
                           nil
                           'KEEP-TIME))
            (error nil)))
      (incf count)
      (setq ptr (cdr ptr)))))
