我在我的Applescript中使用这种语法,但是我找不到错误文件。我确定文件在那里。这有什么不对吗?
set rtfFile to "Macintosh HD:Users:ash:Documents:Core:_Marketing:xlsafe_p.rtf" as alias
答案 0 :(得分:1)
这是一个小程序,用于检查错误发生在路径的哪一点:
set rtfFile to "Macintosh HD:Users:ash:Documents:Core:_Marketing:xlsafe_p.rtf"
checkPath(rtfFile)
on checkPath(aPathToCheck)
set oldATID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set pathElements to text items of aPathToCheck
set AppleScript's text item delimiters to oldATID
set d to ""
set tempPath to ""
repeat with i from 1 to (count pathElements)
set tempPath to tempPath & d & item i of pathElements
try
set foo to tempPath as alias
on error
display alert "The path " & return & tempPath & return & "is not valid!" buttons {"OK"}
return false
end try
set d to ":"
end repeat
display alert "The path " & return & tempPath & return & "is valid!" buttons {"Yeah!"}
return true
end checkPath
这里说路径Macintosh HD:用户:ash无效!因为我使用其他凭据登录而不是你;-)请尝试这个处理程序并告诉我们结果!< / p>
享受,迈克尔/汉堡
答案 1 :(得分:0)
尝试选择带有此文件的文件,从警报中复制文本,然后比较结果。
display alert ((choose file) as text)