Error when save file with script. Adobe illustrator
Copy link to clipboard
Copied
Wrote script to save file.
When try run script in Os mac all is ok, when try it on Windows write this error ( Could not write the file. an assertion has faild )
Why it happens?
Explore related tutorials & articles
Copy link to clipboard
Copied
What is the script? It's probably a path resolution or OS specific issue.
Copy link to clipboard
Copied
Script just save file in jpg and eps) nothing difficult
Copy link to clipboard
Copied
Impossible to debug something we can't see. Can you post what you have regardless of difficulty? Otherwise you expect us to rewrite everything from scratch instead of just pointing out the issue in your code.
Copy link to clipboard
Copied
no problem) take it))
function main () {
var destFile = '/Users/andrey/Desktop';
var newFile = new File(destFile);
// save eps and ai
var saveDoc = app.activeDocument;
var saveEps = new EPSSaveOptions();
var saveAi = new IllustratorSaveOptions();
saveEps.cmykPostScript = false;
saveEps.embedAllFonts = false;
saveAi.compatibility = Compatibility.ILLUSTRATOR17;
saveAi.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
saveDoc.saveAs( newFile, saveEps );
saveDoc.saveAs( newFile, saveAi);
// save jpg
var exportOptions3 = new ExportOptionsJPEG();
var type3 = ExportType.JPEG;
var fileSpec3 = new File(destFile);
exportOptions3.antiAliasing = false;
exportOptions3.qualitySetting = 100;
app.activeDocument.exportFile( fileSpec3, type3, exportOptions3 );
}
main();
Copy link to clipboard
Copied
Hi,
Could you please try your script by changing
var destFile = '/Users/andrey/Desktop';
to
var destFile = Folder.desktop;
So complete script will be like
function main() {
var destFile = Folder.desktop;
var newFile = new File(destFile);
// save eps and ai
var saveDoc = app.activeDocument;
var saveEps = new EPSSaveOptions();
var saveAi = new IllustratorSaveOptions();
saveEps.cmykPostScript = false;
saveEps.embedAllFonts = false;
saveAi.compatibility = Compatibility.ILLUSTRATOR17;
saveAi.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
saveDoc.saveAs(newFile, saveEps);
saveDoc.saveAs(newFile, saveAi);
// save jpg
var exportOptions3 = new ExportOptionsJPEG();
var type3 = ExportType.JPEG;
var fileSpec3 = new File(destFile);
exportOptions3.antiAliasing = false;
exportOptions3.qualitySetting = 100;
app.activeDocument.exportFile(fileSpec3, type3, exportOptions3);
}
main();
Let us know if this works on Windows machine or not.
Copy link to clipboard
Copied
Thaths error again((
Copy link to clipboard
Copied
Please excuse the obvious question, but isn't a root directory required in the path in Windows? So
var destFile = "/C/Users/andrey/Desktop";
Copy link to clipboard
Copied
But I think Folder.desktop will give correct path irrespective of the OS version.
Copy link to clipboard
Copied
May be some permission issues with the Desktop path on Windows. Could not write a file is an error related to the permission. So, you can try by chaning permission or path location.
Copy link to clipboard
Copied
Salut!
Ce script fonctionne sur CS6 Windows 7
avec une de ces deux lignes:
var destFile = '/Users/René/Desktop';
var destFile = '~/Desktop';
Je ne sais pas comment traduire en français le mot Assertion ? (affirmation)
C'est sur le même ordinateur ?
René

