0

我找到了将显示元数据的命令“mdls”,但我看不到如何删除它。

我想从我的文件中删除评论“kMDItemFinderComment”、“kMDItemWhereFroms”。

有没有办法做到这一点?

4

3 回答 3

5

我认为您正在寻找终端中可用的 xattr 命令:

xattr -pr com.apple.metadata:kMDItemFinderComment /

这将打印启动卷上所有文件的所有查找器注释。要删除,请使用 -d 开关:

xattr -dr com.apple.metadata:kMDItemFinderComment /

在批量运行之前,您应该在单个文件上对其进行测试。

usage: xattr [-l] [-r] [-v] [-x] file [file ...]
       xattr -p [-l] [-r] [-v] [-x] attr_name file [file ...]
       xattr -w [-r] [-v] [-x] attr_name attr_value file [file ...]
       xattr -d [-r] [-v] attr_name file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to the string attr_value.
The fourth form (-d) deletes the xattr attr_name.

options:
  -h: print this help
  -r: act recursively
  -l: print long format (attr_name: attr_value and hex output has offsets and
      ascii representation)
  -v: also print filename (automatic with -r and with multiple files)
  -x: attr_value is represented as a hex string for input and output
于 2009-12-14T02:09:30.723 回答
2

您可以通过以下方式做到这一点:

xattr -d com.apple.metadata:kMDItemFinderComment <file>
xattr -d com.apple.metadata:kMDItemWhereFroms <file>

似乎对我有用。

于 2009-12-14T02:10:24.790 回答
0

Spotlight 注释也存储在 .DS_Store 文件中。如果您尝试在 Finder 的信息窗口中添加评论并运行xattr -d com.apple.metadata:kMDItemFinderComment,该评论仍将显示在 Finder 中,但不会显示在 Finder 中mdls -n kMDItemFinderComment。这将删除它们两个:

find . -name .DS_Store -delete
xattr -dr com.apple.metadata:kMDItemFinderComment .
于 2012-09-25T13:18:29.683 回答