递归地扫描一个或多个给定的目录以查找重复的文件。
yadupe的Python项目详细描述
重复播放
yadupe是另一个在系统中查找和删除重复文件的工具。 它将递归地读取源目录,查找重复的文件。如果两个文件具有相同的大小和内容,则被视为重复文件,尽管它们可能具有不同的名称。
在搜索模式实用程序报告重复文件列表。
在重复数据消除模式下,实用工具会将重复文件移动到给定的目标目录中。源目录中只保留一组重复项中的一个文件。此外,包含移动副本的所有路径的报告文件将保存在目标目录中。
先决条件
安装
% pip install yadupe
如果没有pip,安装也很容易:https://pip.pypa.io/en/stable/installing/
安装yadupe后,可以在cli上使用它:
% yadupe -h
用法
- 搜索并删除目录/home/user/source_a,/home/user/source_b中的重复文件。找到的重复项将移动到/home/user/duplicates,以及有关移动文件的报告。也删除了source_a和source_b中的空子文件夹。
% yadupe /home/user/source_a /home/user/source_b -d -p -r /home/user/duplicates
- 在目录/home/user/source_a中搜索重复项并打印重复列表。
% yadupe /home/user/source_a
- 在python应用程序的examples目录中有两个使用yadupe包的示例。
选项
% yadupe -h
usage: yadupe [-h] [-d] [-p] [-r PATH] PATH [PATH ...]
Recursively scan one or more given directories for duplicate files. Found
duplicates list could be saved into report or printed out in console. Also,
duplicates could be moved into destination directory in safe way, preserving
it relative path. In this case file name is written in the report, as well as
new path for the file. If empty sub-directories turn up after duplicates
removal, the could be deleted as well.
positional arguments:
PATH Source path to search duplicated files.
optional arguments:
-h, --help show this help message and exit
-d, --deduplicate Scan and remove mode. Duplicates will be moved into
given directory.
-p, --purge Remove empty subdirs after duplicates move.
-r PATH, --result PATH
Path to report dir (optional for default search mode)
OR directory to move duplicated files into.
测试
要在test目录中运行单元测试,请首先在test-data.zip目录中的test-data存档文件中解压缩。它为测试创建所需的目录树。