如何根据文件内容(忽略文件名)将所有 VCard 文件移动到其他目录
此命令将通过文件内容(不是通过文件扩展名)递归使用 file 命令(查找 text/vcard MIME 类型)识别目录中的所有 VCard 文件,并将它们移动到不同的目录。
move_vcards_by_type.sh
mkdir -p ../VCards && find . -type f -exec sh -c '
case $( file -bi "$1" ) in (text/vcard*) exit 0; esac
exit 1' sh {} \; -exec mv -v --backup=numbered {} ../VCards \;基于此 StackExchange 帖子。另请参阅如何根据文件内容(忽略文件名)将所有图像移动到其他目录和如何根据文件内容(忽略文件名)将所有视频移动到其他目录和如何根据文件内容(忽略文件名)将所有 OOXML (Word .docx/Excel .xlsx) 文件移动到其他目录
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