在左侧寻找Run Apple Script,拖入右侧流程图中。下面的代码将ppt转为pptx并保存在同一文件夹中。若要接受更多格式的后缀名,需要修改makeNewPath部分(这里是将后三位ppt截掉,换成pptx)。
on run {input, parameters}
set output_list to {}
tell application "Microsoft PowerPoint"
launch
set theDial to start up dialog
set start up dialog to false
repeat with i in input
open i
set output_path to my makeNewPath(i)
save active presentation in output_path
close active presentation saving no
set end of output_list to output_path as alias
end repeat
set start up dialog to theDial
quit
end tell
return output_list
end run
on makeNewPath(f)
set t to f as string
return (text 1 thru -4 of t) & "pptx"
end makeNewPath
若要转换为PDF格式,则需将
save active presentation in output_path
一句改为
save active presentation in output_path as save as PDF
并修改makeNewPath的部分:
on makeNewPath(f)
set t to f as string
if t ends with ".pptx" then
return (text 1 thru -5 of t) & "pdf"
else
return t & ".pdf"
end if
end makeNewPath
for f in "$@"
do
unzip "$f" -d "$f Files/"
mkdir "$f Audio"
for file in `ls "$f Files/ppt/media/"`
do
if [ "${file##*.}" = "wav" ]; then
mv -f "$f Files/ppt/media/$file" "$f Audio/"
fi
done
rm -rf "$f Files/"
rm -f "$f"
done
此处有一个问题:在较高版本的macOS中实际执行时会出现读写磁盘权限不足的问题。这时需要对该脚本赋予Full Disk Access权限。打开System Preferences,在Security & Privacy中找到Full Disk Access,左下角解锁后点击加号,将执行该脚本的Finder加入进去并赋予权限。Finder.app的路径在/System/Library/CoreServices中。