如何根据文件内容(忽略文件名)将所有图像移动到其他目录
此命令将使用 file 命令递归识别目录中的所有图像文件(查找 image/* MIME 类型)并将它们移动到不同的目录。
move_images_by_content.sh
mkdir -p ../Images && find . -type f -exec sh -c '
case $( file -bi "$1" ) in (image/*) exit 0; esac
exit 1' sh {} \; -exec mv -v --backup=numbered {} ../Images \;基于此 StackExchange 文章。另请参阅如何根据文件内容(忽略文件名)将所有音频文件移动到其他目录和如何根据文件内容(忽略文件名)将所有视频移动到其他目录和如何根据文件内容(忽略文件名)将所有 PDF 文件移动到其他目录
Check out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow