删除“引用形式”上的引号在苹果脚本中?

发布于 2024-11-15 08:15:18 字数 754 浏览 2 评论 0原文

我有以下代码来复制 Finder 中多个选定项目的路径:

activate application "Finder"
tell application "Finder"
    set theSel to (selection of application "Finder")
    set pathList to {}
    repeat with anItem in theSel
        set the end of pathList to quoted form of (POSIX path of (anItem as alias))
    end repeat
    set savedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "
"
    set the clipboard to pathList as string
    set AppleScript's text item delimiters to savedDelimiters
end tell

唯一的问题是它会导致这样的结果:

'/Applications/Burn.app/'
'/Applications/Caffeine.app/'
'/Applications/Calculator.app/'

这基本上就是我想要的,但我不希望那里有那些该死的单引号。我该如何摆脱它们?我已经尝试删除引用形式但没有运气。

谢谢!

I have the following code to copy paths of multiple selected items in Finder:

activate application "Finder"
tell application "Finder"
    set theSel to (selection of application "Finder")
    set pathList to {}
    repeat with anItem in theSel
        set the end of pathList to quoted form of (POSIX path of (anItem as alias))
    end repeat
    set savedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "
"
    set the clipboard to pathList as string
    set AppleScript's text item delimiters to savedDelimiters
end tell

The only problem is that it results in this:

'/Applications/Burn.app/'
'/Applications/Caffeine.app/'
'/Applications/Calculator.app/'

Thats' basically what I want, but I don't want those damn singlue quotes in there. How do I get rid of them? I already tried just removing quoted form of but without luck.

Thanks!

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

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

发布评论

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

评论(1

意中人 2024-11-22 08:15:18

你所要做的就是取出“引用形式”

    activate application "Finder"
tell application "Finder"
    set theSel to (selection of application "Finder")
    set pathList to {}
    repeat with anItem in theSel
        set the end of pathList to (POSIX path of (anItem as alias))
    end repeat
    set savedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "
"
    set the clipboard to pathList as string
    set AppleScript's text item delimiters to savedDelimiters
end tell

all you have to do is take out "quoted form of "

    activate application "Finder"
tell application "Finder"
    set theSel to (selection of application "Finder")
    set pathList to {}
    repeat with anItem in theSel
        set the end of pathList to (POSIX path of (anItem as alias))
    end repeat
    set savedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "
"
    set the clipboard to pathList as string
    set AppleScript's text item delimiters to savedDelimiters
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文