【发布时间】:2026-01-18 06:30:02
【问题描述】:
我对 AppleScript 不是很熟练,并且对命名和枚举文件和路径的各种方法感到完全困惑。根据我找到的文档和示例,我已经尝试了几乎所有我能做的事情,但是我遇到了我不理解的错误或无法执行任何操作的脚本(我希望如此)。
我认为我的任务相当简单。我正在尝试提供一个我发现的脚本,它可以使用适当的参数执行我需要做的大部分工作,所有这些都是路径或文件名:
on open theFiles
-- Assume dropped files are are in the same folder
-- Call SaveFilesAsSVG to create svg versions of each dropped file next to the originals in the same folder
end open
on run
-- Ask for a destination folder with a defined relative path as the default
-- Ask for a source folder with a defined relative path as a default
-- Call SaveFilesAsSVG to create an svg version of each file with a defined extension found in the source folder in the destination folder
end run
我面临的挑战是以script I've found (p. 182) 期望的形式生成参数:
-- From Adobe:
on SaveFilesAsSVG(fileList, filePath, destFolder)
set destPath to destFolder as string
set fileCount to count of fileList
if fileCount > 0 then
repeat with i from 1 to fileCount
set fileName to item i of fileList
set fullPath to filePath & fileName
set newFilePath to destPath & fileName & ".svg"
tell application "Adobe Illustrator"
open POSIX file fullPath as alias without dialogs
export current document to file newFilePath as SVG ¬
with options {class:SVG export options ¬
, embed raster images:true}
close current document saving no
end tell
end repeat
end if
end SaveFilesAsSVG
在编写我的open 和run 处理程序方面的任何帮助将不胜感激!
【问题讨论】:
标签: path applescript filenames adobe-illustrator