如何查找不属于某种类型的文件?

如何查找不属于某种类型的文件?

我试图找出我的无组织音乐文件夹中的所有不同类型的文件。我一直在尝试这个命令(列出除了我知道的文件类型之外的文件类型):

find zUnorganized/ -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" -or -not -iname "*.m4a" -and -not -iname "*.jpg"

但这不起作用。我该如何让该命令起作用?有没有办法使用 -regex 来做到这一点?

谢谢!

答案1

您写道(为了清楚起见,添加了多余的括号):

find zUnorganized/ \( -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" \) \
               -or \( -not -iname "*.m4a" -and -not -iname "*.jpg" \)

要么使用-and -not全文,要么使用or全文并结束-print(意思是:对此不执行任何操作,否则对此不执行任何操作,等等,否则打印)。您还需要将搜索限制为常规文件,否则将列出目录。

find zUnorganized/ -type f -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" -and -not -iname "*.m4a" -and -not -iname "*.jpg"
find zUnorganized/ \! -type f -o \
                   -iname "*.mp3" -o -iname "*.flac" -o -iname "*.MP3" -o -iname "*.wav" -o -iname "*.m4a" -o -iname "*.jpg" -o \
                   -print

相关内容