10 Replies Latest reply on Feb 9, 2016 4:12 PM by Stephen_A_Marsh

    Adding metadata from another (raster) file to an AI file

    Doug A Roberts Adobe Community Professional & MVP

      Hi all. I've been using the below script to select a folder of JPEGs, place them on an existing AI template file, and save AI files elsewhere. It was cribbed from here originally and messed about with by me until it worked for what I wanted, which it does very nicely.


      What I'm coming up against now is I need a way of applying a set of metadata -- specifically keywords -- quickly to the AI files at the time they're created, hopefully minimizing any manual entry the users will have to do. The JPEGs have (or can have) metadata applied to them via an action when they're saved in PS. But it seems you can't do this in Illustrator. So what I want to know is: can the keywords from the JPEG files be applied to the AI files as they're being saved, and how would one go about this?


      Assume I'm a beginner here. Profuse thanks in advance for any assistance.



      This script gets files specified by the user from the  
      selected folder and batch processes them and saves them  
      as AIs in the user desired destination with the same  
      file name. 
      Modified from Adobe supplied scripts and 
      scripts by Carlos Canto on Illustrator Scripting 
      by Larry G. Schneider 072911 
      Note to Thatcham users: Modified from the above by Douglas Roberts
      // uncomment to suppress Illustrator warning dialogs  
      function jpegMET(){
      app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;  
      var destFolder, sourceFolder, files, fileType;  
      // Select the source folder.  
      sourceFolder = Folder.selectDialog( 'Select the folder containing M.E.T. JPEG files, you beauty', '~' );  
      // If a valid folder is selected  
      if ( sourceFolder != null )  
           files = new Array();  
           // Get all files with JPEG extension
           files = sourceFolder.getFiles("*.jpg");  
           if ( files.length > 0 )  
                // Get the destination to save the files  
                destFolder = Folder.selectDialog( ' Hey buster. Select the folder where you want to save the AI files.', '~' );  
                for ( i = 0; i < files.length; i++ )  
                     var idoc = app.open(File("/G/Design & Publishing/Elements/Master Templates/Re-Engineering Templates/Illustrator/MET Template 106.82x60.ai"));  // open template document. Change the file path for different templates
                     var ilayer = idoc.layers["Image"];
                     var iplaced = ilayer.placedItems.add();  // add image place holder  
                     iplaced.file = (files[i]);  // place file  
                      var PosXY=new Array(2);  // ensure position is 0,0
                      iplaced.position = PosXY;
                     ilayer.dimPlacedImages = false;   // do not dim images        
                     ilayer.locked = true;  // lock layer  
                     ilayer.printable = true;
                     var docName = decodeURI(files[i].name.replace('.jpg', '.ai'));   // take the first part of the placed file name for the new document  
                     var test = destFolder.getFiles(docName);
                     if(test != 0){
                         var overWrite = confirm("A file with this name already exists. Continue and overwrite?");
                         if (overWrite){
                              var destFile = new File(destFolder + "/" +  docName);   // make a new file in the dest folder  
                         var destFile = new File(destFolder + "/" +  docName);   // make a new file in the dest folder  
                     var options = new IllustratorSaveOptions();   // new save options  
                     options.compatibility = Compatibility.ILLUSTRATOR15;   // save as AICS5. May want to update if we go to CC
                     options.pdfCompatible = true; // needs to be set to view links in InDesign
                     // Export as AI  
                     idoc.saveAs(destFile,  options);  // save the file in the dest folder  
                alert( 'Way to go champ! Files are saved as AI in ' + destFolder );  
                // Remove JPEGs from source folder
                var removeFiles = sourceFolder.getFiles();  
                      for(var a=0;a<removeFiles.length;a++){  
                alert( 'No matching files found.' );  
      app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS  
      jpegMET ()