pkolaczk / fclones

Efficient Duplicate File Finder
MIT License
1.96k stars 75 forks source link

Add flag to output symlink instead of target #100

Closed optix2000 closed 2 years ago

optix2000 commented 2 years ago

It would be nice to have a flag to report on the symlink name instead of the target, or treat symlinks as the target files themselves. This would fill a niche where symlinks provide an alternative name that's more useful than the target file name. This also allows flcones to list duplicate symlinks so that they can be cleaned up when the target files are removed.

Say you have the following files structure:

Where /a/file and /b/file are identical files. /c/symlink is a relative symlink to /a/file.

mkdir a b c
dd if=/dev/urandom of=a/file bs=1M count=10
cp a/file b/file
ln -s ../a/file c/symlink

If you use --follow-links, fclones will report on the target file /a/test instead of /c/symlink.

[2022-02-28 08:34:34.340] fclones:  info: Started grouping
[2022-02-28 08:34:34.343] fclones:  info: Scanned 7 file entries
[2022-02-28 08:34:34.343] fclones:  info: Found 2 (21.0 MB) files matching selection criteria
[2022-02-28 08:34:34.343] fclones:  info: Found 1 (10.5 MB) candidates after grouping by size
[2022-02-28 08:34:34.343] fclones:  info: Found 1 (10.5 MB) candidates after grouping by paths and file identifiers
[2022-02-28 08:34:34.343] fclones:  info: Found 1 (10.5 MB) candidates after grouping by prefix
[2022-02-28 08:34:34.343] fclones:  info: Found 1 (10.5 MB) candidates after grouping by suffix
[2022-02-28 08:34:35.188] fclones:  info: Found 1 (10.5 MB) redundant files
# Report by fclones 0.17.1
# Timestamp: 2022-02-28 08:34:35.189 +0000
# Command: fclones group b c --follow-links
# Found 1 file groups
# 10485760 B (10.5 MB) in 1 redundant files can be removed
1c7a31e91b14879d2b050786667f814c, 10485760 B (10.5 MB) * 2:
    /home/user/test/b/test
    /home/user/test/a/test