Question
Read arguments from cmd line for Illustrator script
Hello there,
I'm trying to execute script via cmd terminal & in script I need to read and write file to certain dir basically create a copy of exising work, while checking arguments length is returning 0, as an example here is my script which reads AI file from my local and create an svg write it to destination path, but still getting arguments undefined, Can someone guide me how to get value in scripts from passed string in cmd
Example Script
if (arguments.length < 2) {
alert("Insufficient arguments provided. Expected source and destination file paths.");
quit();
}
try {
var sourceFilePath = arguments[0];
var destFilePath = arguments[1];
var sourceFile = File(sourceFilePath);
var destFile = File(destFilePath);
$.writeln("Source file: " + sourceFile.fsName);
$.writeln("Destination file: " + destFile.fsName);
if (sourceFile.exists) {
var doc = app.open(sourceFile);
var options = new ExportOptionsSVG();
var type = ExportType.SVG;
options.embedRasterImages = true;
doc.exportFile(destFile, type, options);
doc.close(SaveOptions.DONOTSAVECHANGES);
$.writeln("Export successful!");
} else {
$.writeln("Source file does not exist.");
}
} catch (e) {
$.writeln("Error: " + e.message);
}
Terminal
C:\Users\Desktop\ProjectScript>"C:\\Program Files\\Adobe\\Adobe Illustrator CS6 (64 Bit)\\Support Files\\Contents\\Windows\\Illustrator.exe" -r "C:\\Users\\Desktop\\ProjectScript\\src\\Test.jsx" "C:\\Users\\Desktop\\ProjectScript\\assets\\AI_SAMPLE.ai" "C:\\Users\\Desktop\\ProjectScript\\assets\\converted\\SVG_SAMPLE.svg"
Thanks
