好多资源哦

 找回密码
 立即注册
查看: 208|回复: 0

AI脚本 一键存cs6格式脚本

[复制链接]
发表于 2024-8-21 14:06:17 | 显示全部楼层 |阅读模式
可以配合 ai_scriptmix-master 插件使用方便

复制已下内容到记事本打开就行  另存jsx格式

  1. #target illustrator

  2. function saveAsCS6WithDialog() {
  3.     if (app.documents.length > 0) {
  4.         var doc = app.activeDocument;

  5.         // 定义Illustrator CS6的特定格式
  6.         var saveOptions = new IllustratorSaveOptions();
  7.         saveOptions.compatibility = Compatibility.ILLUSTRATOR16; // Illustrator CS6的内部版本号为16

  8.         // 检查是否存在用户上次选择的路径
  9.         var savePath = Folder.myDocuments + "/lastSavePath.txt";
  10.         var saveFolder;

  11.         if (File(savePath).exists) {
  12.             // 读取上次保存路径
  13.             var pathFile = new File(savePath);
  14.             pathFile.open('r');
  15.             var lastPath = pathFile.read();
  16.             pathFile.close();
  17.             saveFolder = new Folder(lastPath);
  18.         } else {
  19.             // 如果没有找到上次保存的路径,则提示用户选择保存路径
  20.             saveFolder = Folder.selectDialog("请选择一个保存路径");
  21.         }

  22.         if (saveFolder != null) {
  23.             // 保存当前路径为下一次使用
  24.             var pathFile = new File(savePath);
  25.             pathFile.open('w');
  26.             pathFile.write(saveFolder.fsName);
  27.             pathFile.close();

  28.             // 构造保存的文件名,添加_CS6后缀
  29.             var originalName = doc.name.replace(/\.[^\.]+$/, ''); // 移除扩展名
  30.             var newName = originalName + "_CS6.ai"; // 添加_CS6后缀和.ai扩展名

  31.             // 保存文件
  32.             var saveFile = new File(saveFolder + "/" + newName);
  33.             doc.saveAs(saveFile, saveOptions);
  34.             alert("文件已保存至: " + saveFolder.fsName);
  35.         } else {
  36.             alert("保存操作已取消。");
  37.         }
  38.     } else {
  39.         alert("没有打开的文档。");
  40.     }
  41. }

  42. saveAsCS6WithDialog();
复制代码




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|好多资源哦

GMT+8, 2024-10-18 18:15 , Processed in 0.104578 second(s), 14 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表