我是一名图形设计师,也是一名编码初学者。所以请帮我简化一下:)
我有一个通过 Illustrator 运行的脚本。它嵌入图像并删除文件上的剪贴蒙版。我需要此脚本在文件夹中的多个 .ai 文件上运行。
问题是,我无法创建批处理操作(在 Illustrator 中)来运行脚本。我们的 IT 人员不想将脚本添加到多个帐户的 Illustrator 设置中。有没有办法向我的脚本添加代码来执行此操作?
我需要它来打开所有文件,运行脚本并保存。这些文件可以在 Illustrator 上保持打开状态,无需关闭。
我需要在脚本中添加哪些代码?
我使用的是 Mac,而不是 PC。
最佳答案
可以这样做:
function my_script() {
// copy a full text of your script here
// or include the jsx file this way:
# include '~/Desktop/script/my_script.jsx'
}
function main() {
var folder = Folder.selectDialog('Please, select the folder');
if (!(folder instanceof Folder)) return;
var files = folder.getFiles('*.ai');
if (files.length == 0) {
alert('Folder doesn\'t content AI files');
return;
}
var i = files.length;
while (i--) {
var doc = app.open(files[i]);
my_script(); // <------- here your script is running
doc.save();
doc.close();
}
alert(files.length + ' files were processed');
}
main();
关于javascript - 对目录中的所有 .ai 文件运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71069458/