【问题标题】:Strip metadata from files in Snow Leopard从 Snow Leopard 中的文件中去除元数据
【发布时间】:2010-12-05 21:29:05
【问题描述】:

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

我想从我的文件中删除 cmets "kMDItemFinderComment"、"kMDItemWhereFroms"。

有没有办法做到这一点?

【问题讨论】:

    标签: macos unix metadata osx-snow-leopard spotlight


    【解决方案1】:

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

    xattr -pr com.apple.metadata:kMDItemFinderComment /
    

    这将打印启动卷上所有文件的所有 finder cmets。要删除,请使用 -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
    

    【讨论】:

    • 哇哦,有办法,没想到可以,谢谢!另外,你从哪里得到的 MAN 信息?我试图在“man xattr”之前寻找它,但我得到的只是“没有手动输入 xattr”
    • 我会点击勾选以接受此解决方案,但它一直出现错误,所以我想您将不得不再等 3 天才能获得赏金 :)
    • 这不是手册页,这只是 xattr --help。我也没有手册页(雪豹)。赏金真是太可惜了,如果我理解正确,如果时间到期,我只会得到一半的赏金。是否有 SO 的支持电子邮件?
    • 哦,好的,太棒了,谢谢。看起来滴答声今天起作用了。享受你的赏金)
    【解决方案2】:

    您可以这样做:

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

    似乎对我有用。

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

      • 我认为,当您错过删除 .DS_Store 评论时,最终聚光灯会再次将其拾起,可能是在同一文件夹中的文件中添加了另一条评论时。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      • 2010-11-23
      • 1970-01-01
      • 1970-01-01
      • 2011-01-19
      • 2011-07-09
      相关资源
      最近更新 更多