sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.91k stars 132 forks source link

Excluding folders when piping from find doesn't work #535

Open TanukiTom opened 2 years ago

TanukiTom commented 2 years ago

I'm trying to exclude certain folders from rmlint by piping the results from find. Here are my files:

/home/me/rmlint-test/scan/test-file.txt
/home/me/rmlint-test/do-not-scan/test-file-copy.txt

I want rmlint to completely ignore all the contents in the do-not-scan folder: find -name "do-not-scan" -prune -o print

Result: /home/me/rmlint-test/scan/test-file.txt

However, this doesn't work when piping the results of find into rmlint: find /home/me/rmlint-test -name "do-not-scan" -prune -o -print0 | rmlint -0 -S l

Result:

Duplicate(s):
ls /home/me/rmlint-test/scan/test-file.txt
rm /home/me/rmlint-test/do-not-scan/test-file-copy.txt

find /home/me/rmlint-test -name "do-not-scan" -prune -o -print | rmlint - -S l gives the same result. I've tried running find with multiple different -name, -path and -prune combinations. I keep having the same problem.

rmlint shouldn't find any duplicates because it shouldn't know about the contents of the do-not-scan folder. find's output excludes the do-not-scan folder, so I don't think the problem is with find. However, I don't know how rmlint could be running on a file, if find isn't passing that file path to rmlint.

cebtenzzre commented 2 years ago

find /home/me/rmlint-test -name "do-not-scan" -prune -o -print0 includes the root directory, which rmlint will scan recursively by default - try find /home/me/rmlint-test -mindepth 1 -name "do-not-scan" -prune -o -print0 to exclude it, or find /home/me/rmlint-test -name "do-not-scan" -prune -o -type f -print0 to only list files (doesn't include symlinks either).