下面是一个使用AppleScript将40段拆分为10个由4段组成的段落的示例代码:
set originalParagraphs to paragraphs of "这里是原始文本内容。" -- 将原始文本内容替换为你自己的文本内容
set newParagraphs to {}
set currentParagraph to ""
repeat with i from 1 to count of originalParagraphs
set currentParagraph to currentParagraph & item i of originalParagraphs & return
if (i mod 4) = 0 then -- 当添加了4段后
set end of newParagraphs to currentParagraph
set currentParagraph to ""
end if
end repeat
-- 检查是否还有剩余的段落未添加到新的段落中
if currentParagraph is not equal to "" then
set end of newParagraphs to currentParagraph
end if
-- 输出新的段落
repeat with i from 1 to count of newParagraphs
display dialog item i of newParagraphs
end repeat
请注意,上述代码中的“这里是原始文本内容。”需要替换为你自己的原始文本内容。这段代码将原始文本拆分为10个由4段组成的段落,并通过对话框显示每个新的段落。
你可以将这段代码复制到Script Editor(脚本编辑器)中运行,然后根据你的需求进行修改。