【问题标题】:mdfind with single quotesmdfind 带单引号
【发布时间】:2015-07-04 09:40:21
【问题描述】:

我正在编写一个applescript,它将根据包含扩展名的文件名为我找到一个文件。该脚本在 bash shell 中使用 mdfind。我对这个结构很幸运:

mdfind 名称:'"filename.avi"'

但是当我的文件名中有一个单引号(撇号)时,它会崩溃,如下所示:

mdfind name:'"MST3K - S05E13 - 不会死的大脑.avi"'

我试图用反斜杠转义单引号,但没有骰子:

mdfind name:'"MST3K - S05E13 - 不会死的大脑.avi"'

我做错了什么?谢谢。

【问题讨论】:

    标签: macos bash applescript spotlight


    【解决方案1】:

    试试这个,并检查结果,这样你就知道应该如何用撇号引用它,当然你应该删除双引号。您还应该打开 mdfind 的手册页,查看 name 命令是如何执行的。

    set q to quoted form of "MST3K - S05E13 - The Brain That Wouldn't Die.avi"
    
    set res to do shell script "mdfind -name 'MST3K - S05E13 - The Brain That Wouldn'\\''t Die.avi'"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-26
      相关资源
      最近更新 更多