Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Javascript to save as template file in predetermined directory with prompt for filename.

$
0
0

I've seen a bunch of examples of how to save a regular illustrator file, but I can't seem to find the syntax for saving a file as a .ait file? Am i just missing something incredibly obvious here?? I know this is not right at all.. but this is what i was able to piece together from others' questions.. But i don't see where or how it calls out what kind of file it's saving..?

 

anyone care to explain the logic in the newName variable? i copied that directly from another post (and edited the file name at the end). What does "/ARTE\..{2,4}$/i" even mean?

 

I'd also like to suppress dialogs while saving as well.

 

thanks all.

 

var sourceName = app.activeDocument.name;
var dest = ('/Volumes/customization/library/cads/');


function saveAsTemplate(destination){
    if(app.documents.length > 0){        var docRef = app.activeDocument;        var cadNumber = prompt("What's the number of this CAD?");        var newName = (sourceName.replace (/ARTE\..{2,4}$/i,'FD-SLOW-SS-' + cadNumber +'.ait');        var AIT = new File(destination);        docRef.saveAs(AIT);    }
} //end function


saveAsTemplate(dest);

Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>