没有更多的废话,直接上代码,代码的注释应该很清楚了。
property word_docs : {"org.openxmlformats.wordprocessingml.document", "com.microsoft.word.doc"}
property default_path : (path to desktop) as alias
property Delim : {".docx", ".doc"}
property PDF : ".pdf"
set outPDF to {}
-- 打开文件选择对话框,只允许选择Word文档,并将所选文件存储在变量 selected_files 中
set selected_files to (choose file of type word_docs default location default_path with multiple selections allowed without invisibles and showing package contents)
-- 将Word文档的扩展名替换为PDF,并将PDF文件路径添加到 outPDF 列表中
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, Delim}
repeat with afile in selected_files
copy item 1 of text items of (afile as text) & PDF to the end of outPDF
end repeat
set AppleScript's text item delimiters to TID
-- 使用Microsoft Word应用程序对象
tell application id "com.microsoft.Word"
-- 将Microsoft Word窗口设置为活动窗口
activate
-- 循环遍历所选的Word文档
repeat with i from 1 to count of s

该脚本使用AppleScript打开文件选择对话框,让用户选择多个Word文档,然后将这些文档转换为PDF格式。它通过MicrosoftWord应用程序进行转换,并处理可能出现的访问权限问题。

2543

被折叠的 条评论
为什么被折叠?



