如何按内容查找重复的jpg? [英] How to find duplicated jpgs by content?

查看:42
本文介绍了如何按内容查找重复的jpg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一系列文件夹中查找和删除图像.问题在于图像名称不一定相同.

I'd like to find and remove an image in a series of folders. The problem is that the image names are not necessarily the same.

我所做的是从图像字节码中复制任意字符串,并像这样使用它

What I did was to copy an arbitrary string from the images bytecode and use it like

grep -ir 'YA'uu�KU���^H2�Q�W^YSp��.�^H^\^Q��P^T' .

但是由于有成千上万张图片,因此这种方法永远有效.另外,有些图像是由原始的imagemagic创建的,因此无法使用尺寸来查找全部图像.

But since there are thousands of images this method lasts for ever. Also, some images are created by imagemagic of the original, so can not use size to find them all.

所以我想知道最有效的方法是什么?

So I'm wondering what is the most efficient way to do so?

推荐答案

更新后的答案

如果您要与特定文件进行校验和比较,则可以对所有子目录中的所有文件进行校验和并找到相同的文件:

If you have the checksum of a specific file in mind that you want to compare with, you can checksum all files in all subdirectories and find the one that is the same:

find . -name \*.jpg -exec bash -c 's=$(md5 < {}); echo $s {}' \; | grep "94b48ea6e8ca3df05b9b66c0208d5184"

或者这也可能对您有用:

Or this may work for you too:

find . -name \*.jpg -exec md5 {} \; | grep "94b48ea6e8ca3df05b9b66c0208d5184"

原始答案

最简单的方法是为每个文件生成一次md5校验和.根据您的 md5 程序的工作方式,您将执行以下操作:

The easiest way is to generate an md5 checksum once for each file. Depending on how your md5 program works, you would do something like this:

find . -name \*.jpg -exec bash -c 's=$(md5 < {}); echo $s {}' \;

94b48ea6e8ca3df05b9b66c0208d5184 ./a.jpg
f0361a81cfbe9e4194090b2f46db5dad ./b.jpg
c7e4f278095f40a5705739da65532739 ./c.jpg

或者也许您可以使用

md5 -r *.jpg
94b48ea6e8ca3df05b9b66c0208d5184 a.jpg
f0361a81cfbe9e4194090b2f46db5dad b.jpg
c7e4f278095f40a5705739da65532739 c.jpg

现在,您可以使用 uniq 查找所有重复项.

Now you can use uniq to find all duplicates.

这篇关于如何按内容查找重复的jpg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆