列表中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'open'命令.
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屋!