【问题标题】:Running a script on all .ai files in a directory对目录中的所有 .ai 文件运行脚本
【发布时间】:2022-02-11 08:36:20
【问题描述】:

我是一名平面设计师,也是编码的初学者。所以请为我哑口无言:)

我有一个通过 Illustrator 运行的脚本。它嵌入图像并删除文件上的剪贴蒙版。我需要这个脚本在一个文件夹中的多个 .ai 文件上运行。

问题是,我无法创建批处理操作(在 Illustrator 中)来运行脚本。我们的 IT 人员不想将脚本添加到多个帐户的 Illustrator 设置中。有没有办法在我的脚本中添加代码来做到这一点?

我需要它来打开所有文件、运行脚本并保存。文件可以在 Illustrator 上保持打开状态,无需关闭。

我需要在脚本中添加什么代码?

我使用的是 Mac 而不是 PC。

【问题讨论】:

    标签: javascript loops adobe-illustrator


    【解决方案1】:

    可以这样做:

    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();
    

    【讨论】:

      猜你喜欢
      • 2021-02-19
      • 1970-01-01
      • 1970-01-01
      • 2021-04-20
      • 2018-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多