来自列表的applescript 中的POSIX 路径未打开.原始路径有效 [英] POSIX path in applescript from list not opening. Raw path works
问题描述
我对这个真的很困惑.我只想打开列表中的文件.这是我的代码
I'm really confused with this one. All I want is the files in the list to open. Here's my codes
set FilesList to {"Users/XXXXXX/Documents/07PictureArt-Related/THINGS THAT HELP/Tutorials/artNotesfromFeng.rtf", "Users/XXXXXXXX/Documents/07PictureArt-Related/THINGS THAT HELP"}
repeat with theFiles in FilesList
delay 0.1
tell application "Finder" to open POSIX file (theFiles)
end repeat
那么,为什么那行不通,但这个行得通???
So, how come THAT won't work, but this will???
tell application "Finder" to open POSIX file "Users/XXXXXX/Documents/07PictureArt-Related/THINGS THAT HELP/Tutorials/artNotesfromFeng.rtf"
我在想这可能与列表使它成为一个字符串有关,当我将它直接插入 open 命令时,它看起来像一个字符串,但它不是真的......我不知道
I'm thinking it might have to do with maybe the list is making it a string, and when I plug it directly into the open command, it LOOKS like a string, but it's not really...I don't know
现在我想我只需要强制执行它,并为每个文件创建一个新语句.
For now I guess I just have to brute force it, and make a new statement for each file.
谢谢
推荐答案
不确定那里发生了什么,我同意它令人困惑.
Not sure what is going on there, i agree it's confusing.
另一种方法是改用 shell 的打开"命令.
An alternate is to use the shell 'open' command instead.
repeat with filePath in FilesList
do shell script "open " & quoted form of filePath
end repeat
shell 似乎更喜欢 POSIX 路径,诀窍是发送 POSIX 路径的引用形式".
The shell seems more happy with POSIX paths, the trick is to send in the 'quoted form' of your POSIX paths.
--首先放入 var 也有效.
-- Putting into a var first works too.
repeat with theFiles in FilesList
set f to POSIX file theFiles
tell application "Finder" to open f
end repeat
似乎 Finder 导致了对 POSIX 文件的强制问题.
It seems the Finder is causing the coercion to POSIX file problem.
这篇关于来自列表的applescript 中的POSIX 路径未打开.原始路径有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!