从 Snow Leopard 中的文件中删除元数据

发布于 2024-08-06 23:14:38 字数 122 浏览 6 评论 0原文

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

我想从我的文件中删除注释“kMDItemFinderComment”、“kMDItemWhereFroms”。

有办法做到这一点吗?

I found the command "mdls" which will show the metadata but I can't see how to delete it.

I want to get rid of the comments "kMDItemFinderComment", "kMDItemWhereFroms" from my files.

Is there a way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁月无声 2024-08-13 23:14:38

我认为您正在寻找终端中可用的 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

I think you're looking for the xattr command, available in Terminal:

xattr -pr com.apple.metadata:kMDItemFinderComment /

that will print all the finder comments for all files on your boot volume. To delete, use the -d switch:

xattr -dr com.apple.metadata:kMDItemFinderComment /

You should test this out on a single file before running it in bulk.

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
神爱温柔 2024-08-13 23:14:38

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

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

似乎对我有用。

You can do this by:

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

Seems to work for me.

记忆消瘦 2024-08-13 23:14:38

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

find . -name .DS_Store -delete
xattr -dr com.apple.metadata:kMDItemFinderComment .

The Spotlight comments are also stored in .DS_Store files. If you try adding a comment in Finder's information window and running xattr -d com.apple.metadata:kMDItemFinderComment, the comment will still be shown in Finder, but not by mdls -n kMDItemFinderComment. This would delete both of them:

find . -name .DS_Store -delete
xattr -dr com.apple.metadata:kMDItemFinderComment .
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文