Applescript:预期表达但发现“/”

时间:2014-05-14 19:27:20

标签: applescript

我正在寻找一个脚本,将我在Safari中打开的标签的网址保存到文本文档中,以便我以后可以打开它们(10个以上的标签页)。我在网上找到了这个脚本:

[applescript]
tell application "Safari"

--Variables
set windowCount to number of windows
set docText to ""

--Repeat for Every Window
repeat with x from 1 to windowCount
set tabcount to number of tabs in window x

--Repeat for Every Tab in Current Window
repeat with y from 1 to tabcount

--Get Tab Name & URL
set tabName to name of tab y of window x
set tabURL to URL of tab y of window x

set docText to docText & "<a href=" & "\"" & tabURL & "\">" & tabName & "</a>" & linefeed as string
end repeat

end repeat
end tell

--Write Document Text
tell application "TextEdit"
activate
make new document
set the text of the front document to docText
end tell

[/applescript]

但是当我尝试运行时,我收到了错误

  

预期表达,但找到&#34; /&#34;

它标志着最后一行,[/ applescript]是错误的。我已经搜索了错误,但似乎无法找到它。有人有个主意吗?

2 个答案:

答案 0 :(得分:2)

将脚本放入AppleScript编辑器时,您可能应删除[applescript][/applescript]行。

答案 1 :(得分:2)

删除[applescript][/applescript]