[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dired-duplicates 4318c0c420 06/57: Sort files by name a
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/dired-duplicates 4318c0c420 06/57: Sort files by name and grouped results by file size |
|
Date: |
Sat, 4 Nov 2023 06:58:26 -0400 (EDT) |
branch: externals/dired-duplicates
commit 4318c0c420ae10892f15918b458bf466edad0b79
Author: Harald Judt <h.judt@gmx.at>
Commit: Harald Judt <h.judt@gmx.at>
Sort files by name and grouped results by file size
Sort files by name (ascending) and grouped results by file size
(descending). A
future commit will allow to choose sorting by file size in ascending or
descending order.
---
find-dupes-dired.el | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/find-dupes-dired.el b/find-dupes-dired.el
index 9c7b15ec5f..79ea044260 100644
--- a/find-dupes-dired.el
+++ b/find-dupes-dired.el
@@ -39,7 +39,8 @@
(defun find-dupes--duplicate-files (directories)
"Given one or more root directories, search inside below the
directories for duplicate files. Returns a hash-table with the
-generated checksums as keys and files as values."
+checksums as keys and a list of size and duplicate files as
+values."
(cl-loop with files = (mapcan #'(lambda (d) (directory-files-recursively d
".*"))
(ensure-list directories))
and same-size-table = (make-hash-table)
@@ -55,18 +56,29 @@ generated checksums as keys and files as values."
for checksum = (find-dupes-checksum-file f)
do (setf (gethash checksum checksum-table)
(append (gethash checksum
checksum-table) (list f)))))
- (cl-loop for checksum being the hash-key in checksum-table using
(hash-value same-files)
- when (< (length same-files) 2) do
- (remhash checksum checksum-table))
+ (cl-loop with size
+ for same-files being the hash-value in checksum-table
using (hash-key checksum)
+ do
+ (if (> (length same-files) 1)
+ (setf (gethash checksum checksum-table)
+ (cons (file-attribute-size (file-attributes
(first same-files)))
+ (sort same-files #'string<)))
+ (remhash checksum checksum-table)))
(cl-return checksum-table)))
(defun find-dupes--generate-dired-list (&optional directories)
"Generate a list of grouped duplicate files, separated by a
separator file specified by `find-dupes-separator-file'."
(cl-loop with dupes-table = (find-dupes--duplicate-files (or directories
-
find-dupes-directories))
- for files being the hash-values in dupes-table
- appending (append files (list find-dupes-separator-file))))
+
find-dupes-directories))
+ with sorted-sums = (cl-sort
+ (cl-loop for k being the hash-key in
dupes-table using (hash-value v)
+ collect (list k (first v)))
+ #'>
+ :key #'second)
+ for (checksum) in sorted-sums
+ append (rest (gethash checksum dupes-table))
+ append (list find-dupes-separator-file)))
(defun find-dupes-revert-function (&optional arg noconfirm)
"Revert function used instead of `dired-revert' for dired buffers generated
by find-dupes."
- [elpa] branch externals/dired-duplicates created (now ec0a89ca32), ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates c48a7901a4 04/57: Format truncated-dirs to one-line, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 4318c0c420 06/57: Sort files by name and grouped results by file size,
ELPA Syncer <=
- [elpa] externals/dired-duplicates c1d40d392f 16/57: Add missing customization group definition, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 9dce08f215 09/57: Add auto-load and end comment, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 07860e81b4 17/57: Require cl-lib, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates b3d03d2f9f 18/57: Rename find-dupes-use-separator-file to find-dupes-use-separators, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 9f78542fd1 20/57: Add lexical binding declaration, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 5b9d946fbb 24/57: Require dired, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 4bd4f6ff94 27/57: flymake: Add package name and small description line, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 2c9131c639 32/57: Add .gitignore file, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates d50460da29 34/57: Unquote lambda, ELPA Syncer, 2023/11/04
- [elpa] externals/dired-duplicates 6aa879e46a 35/57: Use temporary-file-directory instead of hard-coded /tmp, ELPA Syncer, 2023/11/04