使用 adobe illustrator 命令行或批量转换将 .ai 转换为 .svg 文件

Ana*_*d P 6 adobe command adobe-illustrator command-line-interface batch-processing

我有 adobe illustrator 工具,我需要将大量 .ai 文件转换为 svg 文件,而无需在 adobe illustrator 中打开它。只需通过批量转换或命令行 (CLI) 执行即可。

我有 inkscape 工具,它实际上也有一个命令行

转换 test.ai test.svg 但 inkscape 没有给出预期的输出格式

对于插画家,我尝试过以下命令

“C:\Program Files\Adobe\Adobe Illustrator CS6(64 位)\Support Files\Contents\Windows\Illustrator.exe” “C:\Program Files\Adobe\Adobe Illustrator CC 2018\Presets\en_GB\Scripts\SaveDocsAsSVG。 jsx"

它说没有打开的文档!警报

这是我一直在使用的脚本

// 主要代码 [脚本执行从这里开始]

try {
    if (app.documents.length > 0 ) {

        // Get the folder to save the files into
        var destFolder = null;
        destFolder = Folder.selectDialog( 'Select folder for SVG files.', '~' );

        if (destFolder != null) {
            var options, i, sourceDoc, targetFile;  

            // Get the SVG options to be used.
            options = this.getOptions();
            // You can tune these by changing the code in the getOptions() function.

            for ( i = 0; i < app.documents.length; i++ ) {
                sourceDoc = app.documents[i]; // returns the document object

                // Get the file to save the document as svg into
                targetFile = this.getTargetFile(sourceDoc.name, '.svg', destFolder);

                // Save as SVG
                sourceDoc.exportFile(targetFile, ExportType.SVG, options);
                // Note: the doc.exportFile function for SVG is actually a Save As
                // operation rather than an Export, that is, the document's name
                // in Illustrator will change to the result of this call.               
            }
            alert( 'Documents saved as SVG' );
        }
    }
    else{
        throw new Error('There are no document open!');
    }
}
catch(e) {
    alert( e.message, "Script Alert", true);
}
Run Code Online (Sandbox Code Playgroud)

/** 返回用于生成文件的选项。@return ExportOptionsSVG对象*/

function getOptions()
{
    // Create the required options object
    var options = new ExportOptionsSVG();
    // See ExportOptionsSVG in the JavaScript Reference for available option

    return options;
}
/** Returns the file to save or export the document into.
@param docName the name of the document
@param ext the extension the file extension to be applied
@param destFolder the output folder
@return File object */

function getTargetFile(docName, ext, destFolder) {
    var newName = "";

    // if name has no dot (and hence no extension),
    // just append the extension
    if (docName.indexOf('.') < 0) {
        newName = docName + ext;
    } else {
        var dot = docName.lastIndexOf('.');
        newName += docName.substring(0, dot);
        newName += ext;
    }

    // Create the file object to save to
    var myFile = new File( destFolder + '/' + newName );

    // Preflight access rights
    if (myFile.open("w")) {
        myFile.close();
    }
    else {
        throw new Error('Access is denied');
    }
    return myFile;
}
Run Code Online (Sandbox Code Playgroud)

如何在不打开AI的情况下转换文件